Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / linker problem.

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. linker problem.
#3514
Posted by: 2004-03-16 11:13:30
Hey all,

I am having a problem with my make file. I have 6 files:

- myGLCanvas.h // a class that subclasses wxGLCanvas
- myGLCanvas.cpp // myGLCanvas.h implementation
- myFrame.h // a class that subclasses wxFrame
- myFrame.cpp // myFrame.h implementation
- wxOpenGL.h // a class that subclasses wxApp
- wxOpenGL.cpp // wxOpenGL.h implementation

So, when I compile the myGLCanvas.o file, no problem, when I compile the myFrame.o file, no problem and when I compile the wxOpenGL.o file, no problem. All of these just listed compile flawlessly and create my .o files - no problem.

However, whenever I try to build the executable which depends on all of the above o files, I get the following errors:

myGLCanvas.o(.text+0xc):myGLCanvas.cpp: undefined reference to `wxGLCanvas::sm_eventTable'
myGLCanvas.o(.text+0x98):myGLCanvas.cpp: undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)'
myGLCanvas.o(.text+0x158):myGLCanvas.cpp: undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)'
myGLCanvas.o(.text+0x1b1):myGLCanvas.cpp: undefined reference to `wxGLCanvas::~wxGLCanvas()'
myGLCanvas.o(.text+0x1d1):myGLCanvas.cpp: undefined reference to `wxGLCanvas::~wxGLCanvas()'
myGLCanvas.o(.text+0x1f2):myGLCanvas.cpp: undefined reference to `wxGLCanvas::~wxGLCanvas()'
myGLCanvas.o(.text+0x247):myGLCanvas.cpp: undefined reference to `myGLCanvas::OnSize(wxSizeEvent&)'
myGLCanvas.o(.text+0x259):myGLCanvas.cpp: undefined reference to `myGLCanvas::OnPaint(wxPaintEvent&)'
myGLCanvas.o(.text$_ZNK10wxGLCanvas12GetClassInfoEv+0x2):myGLCanvas.cpp: undefined reference to `wxGLCanvas::sm_classwxGLCanvas'
make: *** [wxOpenGL.exe] Error 1

----------------------------------------------------------------------------------------------
Here is my make file:
----------------------------------------------------------------------------------------------

# Project: wxOpenGL
# Makefile created by Dev-C++ 4.9.8.0

CPP  = g++.exe
LIBS =  -L"C:/apps/Dev-Cpp/lib" -mwindows -lwxmswu -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid  
INCS =  -I"C:/apps/Dev-Cpp/include"
CXXINCS =  -I"C:/apps/Dev-Cpp/include/c++"  -I"C:/apps/Dev-Cpp/include/c++/mingw32"  -I"C:/apps/Dev-Cpp/include/c++/backward"  -I"C:/apps/Dev-Cpp/include"
BIN  = wxOpenGL.exe
CXXFLAGS = $(CXXINCS)-D_X86_=1 -DWIN32 -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -D__WIN32__ -mthreads -DSTRICT  -D__WXMSW__ -D__WINDOWS__ -Wall -fno-pcc-struct-return -O2 -fno-rtti -fno-exceptions 
CFLAGS = $(INCS)

#.PHONY: all all-before all-after clean clean-custom

#all: all-before wxOpenGL.exe all-after


#clean: clean-custom
#    rm -f *.o $(BIN)

$(BIN): wxOpenGL.o myFrame.o myGLCanvas.o
   $(CPP) wxOpenGL.o myFrame.o myGLCanvas.o -o "wxOpenGL.exe" $(LIBS) $(CFLAGS)

wxOpenGL.o: wxOpenGL.h wxOpenGL.cpp myFrame.o
   $(CPP) -c wxOpenGL.cpp $(CXXFLAGS)

myFrame.o: myFrame.h myFrame.cpp myGLCanvas.o
   $(CPP) -c myFrame.cpp $(CXXFLAGS)

myGLCanvas.o: myGLCanvas.h myGLCanvas.cpp
   $(CPP) -c myGLCanvas.cpp $(CXXFLAGS)


Can you see anything that is amiss? Any help would be greatly appreciated.

:o)
Message2. Re: linker problem.
#3517
Posted by: upCASE 2004-03-16 18:05:27
Hi!
My guess is, that you're using a lib that wasn't compiled with OpenGL support. So, there is no wxGLCanvas and that's why you get the undefined references.
Solution: Check if wxUSE_GLCANVAS is set in setup.h (or use --with-opengl using configure). Recompile the lib.

upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: linker problem.
#3519
Posted by: 2004-03-17 06:04:56

Thanks for the info. Yeah, what I did was uninstalled Dev-C++, reinstalled a newer version of it, reinstalled newer packages of the wxWindows pak files into Dev-C++, touched up my makefile and prestomatic, I have my clean compile and my OpenGL panel inside of my frame. Thank you again for your time.

I must say that I'm really impressed by this wxWindows API. It is orders of magnitude easier to program for and I'm not just talking about in C++ either. I'm comparing this to MFC, Delphi, and even Java Swing. The wxWindows API is well documented and logically laid out in such a way that GUI creation is straight forward. This is a good thing considering how much of a pain in the behind GUI programming can be at times.



arron
Message4. Re: linker problem.
#4028
Posted by: 2004-05-05 09:13:01
You seem to have had the exact same problem as i have.  I'm running DevC++ 4.9.8.7(just updated, have also tried 4.9.8.0) and have the WxWidgets 2.4.2 DevPak installed.  I just can't seem to get around this linker error when it tries to compile the exe.  All the errors involve wxGlCanvas.  I have set the setup.h file to use wxGlCanvas 1.  That fixed a slew of errors but i still have the same bunch that kill me.  The errors are as follows:
 
Building Makefile: "C:\Documents and Settings\Adam\Desktop\test3\Makefile.win"
Executing  make...
make.exe -f "C:\Documents and Settings\Adam\Desktop\test3\Makefile.win" all
g++.exe -c cube.cpp -o cube.o -I"C:/Dev-Cpp/include/c++"  -I"C:/Dev-Cpp/include/c++/mingw32"  -I"C:/Dev-Cpp/include/c++/backward"  -I"C:/Dev-Cpp/include" -DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -D__WIN32__ -DHAVE_W32API_H  -D__WXMSW__ -D__WINDOWS__ -Wall -fno-pcc-struct-return -O2 -Os -fno-rtti -fno-exceptions 
 
g++.exe cube.o Project1_private.res -o "Project1.exe" -L"C:/Dev-Cpp/lib" -mwindows -Wl,--subsystem,windows -mwindows -lwxmsw -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid   ../../../../Dev-Cpp/lib/libopengl32.a ../../../../Dev-Cpp/lib/libglu32.a ../../../../Dev-Cpp/lib/libwxmsw.a
 
cube.o(.text+0xf38):cube.cpp: undefined reference to `wxGLCanvas::sm_eventTable'
cube.o(.text+0xf64):cube.cpp: undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, wxGLCanvas const*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)'
cube.o(.text+0xfc0):cube.cpp: undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, wxGLCanvas const*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)'
cube.o(.text+0x1024):cube.cpp: undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, wxGLContext const*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)'
cube.o(.text+0x108c):cube.cpp: undefined reference to `wxGLCanvas::wxGLCanvas(wxWindow*, wxGLContext const*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)'
cube.o(.text+0x10d6):cube.cpp: undefined reference to `wxGLCanvas::~wxGLCanvas()'
cube.o(.text+0x10ec):cube.cpp: undefined reference to `wxGLCanvas::~wxGLCanvas()'
cube.o(.text+0x1103):cube.cpp: undefined reference to `wxGLCanvas::~wxGLCanvas()'
cube.o(.text+0x1140):cube.cpp: undefined reference to `wxGLCanvas::SetCurrent()'
cube.o(.text+0x141b):cube.cpp: undefined reference to `wxGLCanvas::SwapBuffers()'
cube.o(.text+0x1482):cube.cpp: undefined reference to `wxGLCanvas::OnSize(wxSizeEvent&)'
cube.o(.text+0x14a7):cube.cpp: undefined reference to `wxGLCanvas::SetCurrent()'
 
cube.o(.text+0x14cd):cube.cpp: undefined reference to `wxGLCanvas::SetCurrent()'
cube.o(.text+0x178b):cube.cpp: undefined reference to `wxGLCanvas::SetCurrent()'
cube.o(.text$_ZNK10wxGLCanvas12GetClassInfoEv+0x2):cube.cpp: undefined reference to `wxGLCanvas::sm_classwxGLCanvas'
 
make.exe: *** [Project1.exe] Error 1
 
Execution terminated
 
And here's my makefile:
 
# Project: Project1
# Makefile created by Dev-C++ 4.9.8.7
 
CPP  = g++.exe
CC   = gcc.exe
WINDRES = windres.exe
RES  = Project1_private.res
OBJ  = cube.o $(RES)
LINKOBJ  = cube.o $(RES)
LIBS =  -L"C:/Dev-Cpp/lib" -mwindows -Wl,--subsystem,windows -mwindows -lwxmsw -lstdc++ -lgcc -lodbc32 -lwsock32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid   ../../../../Dev-Cpp/lib/libopengl32.a ../../../../Dev-Cpp/lib/libglu32.a ../../../../Dev-Cpp/lib/libwxmsw.a
INCS =  -I"C:/Dev-Cpp/include"
CXXINCS =  -I"C:/Dev-Cpp/include/c++"  -I"C:/Dev-Cpp/include/c++/mingw32"  -I"C:/Dev-Cpp/include/c++/backward"  -I"C:/Dev-Cpp/include"
BIN  = Project1.exe
CXXFLAGS = $(CXXINCS)-DWINVER=0x0400 -D__WIN95__ -D__GNUWIN32__ -D__WIN32__ -DHAVE_W32API_H  -D__WXMSW__ -D__WINDOWS__ -Wall -fno-pcc-struct-return -O2 -Os -fno-rtti -fno-exceptions 
CFLAGS = $(INCS)
 
.PHONY: all all-before all-after clean clean-custom
 
all: all-before Project1.exe all-after
 

clean: clean-custom
 rm -f $(OBJ) $(BIN)
 
$(BIN): $(OBJ)
 $(CPP) $(LINKOBJ) -o "Project1.exe" $(LIBS)
 
cube.o: cube.cpp
 $(CPP) -c cube.cpp -o cube.o $(CXXFLAGS)
 
Project1_private.res: Project1_private.rc cube.rc
 $(WINDRES) -i Project1_private.rc -I rc -o Project1_private.res -O coff
 
n the forum you said  "...what I did was uninstalled Dev-C++, reinstalled a newer version of it, reinstalled newer packages of the wxWindows pak files into Dev-C++, touched up my makefile..." I've got the newest of everything so the only thing i've got left to do is touch up the makefile apparently?  I've no idea what needs changing.. if anything at all. 

Any help would be greatly appreciated!
Message5. Re: linker problem.
#4035
Posted by: upCASE 2004-05-05 14:53:05
Hi!
"I've got the newest of everything" -> Sure? :)
The problem is not about having a version other than 2.4.2 or a recent devpack, it's about having a wxWidgets lib that was compiled with support for OpenGL. Since you can leave that support out when compiling, you may have a depack that doesn't support it. So, unless you get one with support for GL or compile the lib yourself, you won't be able to compile any OpenGL stuff, just because the wxGLCanvas class isn't there...
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message6. compilation error
#4370
Posted by: 2004-06-08 02:13:12
I am new to dev-c++ I have 3.2 ver of it. While compiling the demo file provided with it I got the following error

cpp: D:\WINDOWS\TEMP\cc000908.i: Bad file descriptor
D:\DEV-C_~1\Bin\windres: gcc exited with status 1
D:\DEV-C_~1\Bin\windres: can't execute `gcc': No error

I have winXP running on celeron 2Ghz processor, can someone help.
Thx in adv.
Message7. Re: linker problem.
#4384
Posted by: upCASE 2004-06-08 15:02:11
Hi!
First of all be sure to post to a NEW thread if it is a NEW question.
Be a bit more specific on what seems to be that problem, like which demo file file do you mean, version of mingw etc... At the moment your question is more like: I've got Windows and when I open a text in notepad it mumbels something about a crash...

"dev-c++ I have 3.2 ver of it" -> Version 3.2 of Dev-C++ or Mingw?? If it's Dev-C++ (I never knew there was such a version) -> Update, now!
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message8. Re: linker problem.
#4471
Posted by: 2004-06-16 08:23:14
Hei upCase,

You should try to edit the setup.h in dev-cpp/include/wx/

change wxUSE_GLCanvas from 0 to 1.
thats all.

hope it help

i have difficulty at first people just say setup.h but never mention the place :(
Message9. Re: linker problem.
#4478
Posted by: upCASE 2004-06-16 15:04:31
Hi!
If WXDIR is the dir where you unzipped wxWidgets to, WXDIR\include\setup.h is the location. Maybe it's in WXDIR\include\msw\setup.h. Copy it over to the first location.
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message10. Re: linker problem.
#5002
Posted by: 2004-08-18 16:58:51
Can anyone tell me what did u do to the setup.h when u change some viarables.... in tis case is... change wxUSE_GLCanvas from 0 to 1.

How do you recompile it? I go thru some postings.. and see that u have to delete away the file.o (object file ) first b4 recompiling... where do u find this object file? can't we overwrite by recompiling the setup.h again?
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2022-12-9  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0