Author Topic: Problem porting from DevC++ to C:B  (Read 7952 times)

xtracto

  • Guest
Problem porting from DevC++ to C:B
« on: November 24, 2005, 07:24:03 pm »
Well, I have a DevC++ project.
 It is quite complex, so far I am using:
- OpenGL
- SDL
- wxWidgets
- mingW

I am trying to test the C:B project to see if I migrate form DevC++. So I open the program and import the DevC++ project [Project/Import/DevC++ Project]

Everything went so-so, Somehow the Output Filename managed to get wrong (something like "H:\my document\H:\my documents". Anyway, that was easy to fix.

Then I made sure the MingW installation with al the needed libraries (for the tools mentioned before) was beeing used, everything ok.


Then I try to rebuild all [Build/Rebuild All] and all the files compile so far, but I got some nasty errors:

Project   : Hanjie3D
Compiler  : GNU GCC Compiler (called directly)
Directory : H:\My Documents\Programs\Hanjie3D\
--------------------------------------------------------------------------------
Switching to target: default
Linking executable: H:\My Documents\Programs\Hanjie3D\Hanjie3D.exe
C:\Dev-Cpp\lib/libwx_mswu-2.6.a(monolib_string.o)(.text+0x2b70):string.cpp: multiple definition of `wxString::wxString(char const*, wxMBConv&, unsigned int)'
..\Hanjie3D\gui.o(.text$_ZN8wxStringC1EPKcR8wxMBConvj[wxString::wxString(char const*, wxMBConv&, unsigned int)]+0x0):gui.cpp: first defined here
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: C:\Dev-Cpp\lib/libwx_mswu-2.6.a(monolib_stattext.o): warning: duplicate section `.rdata$_ZTV16wxStaticTextBase[vtable for wxStaticTextBase]' has different size
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: C:\Dev-Cpp\lib/libwx_mswu-2.6.a(monolib_nativdlg.o): warning: duplicate section `.rdata$_ZTV16wxStaticTextBase[vtable for wxStaticTextBase]' has different size
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: C:\Dev-Cpp\lib/libwx_mswu-2.6.a(monolib_dlgcmn.o): warning: duplicate section `.rdata$_ZTV16wxStaticTextBase[vtable for wxStaticTextBase]' has different size
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2
\..\..\..\..\mingw32\bin\ld.exe: C:\Dev-Cpp\lib/libwx_mswu-2.6.a(monolib_prntdlgg.o): warning: duplicate section `.rdata$_ZTV16wxStaticTextBase[vtable for wxStaticTextBase]' has different size
C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: C:\Dev-Cpp\lib/libwx_mswu-2.6.a(monolib_prntbase.o): warning: duplicate section `.rdata$_ZTV16wxStaticTextBase[vtable for wxStaticTextBase]' has different size
..\Hanjie3D\gui.o(.text+0x3dd):gui.cpp: undefined reference to `wxString::Printf(char const*, ...)'
..\Hanjie3D\gui.o(.text$_ZN12wxStringBaseC2EPKcj[wxStringBase::wxStringBase(char const*, unsigned int)]+0x23):gui.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
..\Hanjie3D\gui.o(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x25):gui.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
..\Hanjie3D\gui.o(.text$_ZN8wxString6appendEjc[wxString::append(unsigned int, char)]+0x22):gui.cpp: undefined reference to `wxStringBase::append(unsigned int, char)'
..\Hanjie3D\gui.o(.text$_ZN12wxStringBase10ConcatSelfEjPKc[wxStringBase::ConcatSelf(unsigned int, char const*)
]+0x22):gui.cpp: undefined reference to `wxStringBase::ConcatSelf(unsigned int, char const*, unsigned int)'
..\Hanjie3D\gui.o(.rdata$_ZTV5MyApp[vtable for MyApp]+0x68):gui.cpp: undefined reference to `wxApp::Initialize(int&, char**)'
..\Hanjie3D\gui.o(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x138):gui.cpp: undefined reference to `wxWindow::RegisterHotKey(int, int, int)'
..\Hanjie3D\gui.o(.rdata$_ZTV7MyFrame[vtable for MyFrame]+0x13c):gui.cpp: undefined reference to `wxWindow::UnregisterHotKey(int)'
..\Hanjie3D\gui.o(.rdata$_ZTV16wxStaticTextBase[vtable for wxStaticTextBase]+0x138):gui.cpp: undefined reference to `wxWindow::RegisterHotKey(int, int, int)'
..\Hanjie3D\gui.o(.rdata$_ZTV16wxStaticTextBase[vtable for wxStaticTextBase]+0x13c):gui.cpp: undefined reference to `wxWindow::UnregisterHotKey(int)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 8 seconds)


Mainly, some wxWidgets functions dont want to be digested using C:B configuration... from my previous experience with DevC++ I *think* this may be fixed modyfing the order of the libraries being lined, but I have tried without a good result.

Of course I think I do not have to mention the project was compiling OK on DevC++. Yes, I am using the same mingW path to compile via Code:Blocks, I *thought* it was going to be more straight forward.

Any help?

Thank you!

btw, I think the CTRL+C shortcut is not working in the C:B build log window

xtracto

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Problem porting from DevC++ to C:B
« Reply #1 on: November 24, 2005, 08:49:27 pm »
It appears you're linking the same library twice... perhaps in your GLOBAL options you got the wxwidgets library....

but the "different size" makes me think you're trying to link to another different wxwidgets library... maybe you got your lib paths wrong...

C:\Dev-Cpp\lib/libwx_mswu-2.6.a(monolib_string.o)(.text+0x2b70):string.cpp: multiple definition of `wxString::wxString(char const*, wxMBConv&, unsigned int)'
..\Hanjie3D\gui.o(.text$_ZN8wxStringC1EPKcR8wxMBConvj[wxString::wxString(char const*, wxMBConv&, unsigned int)]+0x0):gui.cpp: first defined here

I have a hunch... do you have defined in your project, WXUSINGDLL  (for compiler)? It seems to try to link to wxwidgets statically...

Other than that, I couldn't tell. Try enabling the "full commandline" on your compiler options so we can help you troubleshoot.
« Last Edit: November 24, 2005, 08:52:39 pm by rickg22 »

xtracto

  • Guest
Re: Problem porting from DevC++ to C:B
« Reply #2 on: November 25, 2005, 06:26:49 pm »
Hello, I have tried without luck. :(

It appears you're linking the same library twice... perhaps in your GLOBAL options you got the wxwidgets library....

but the "different size" makes me think you're trying to link to another different wxwidgets library... maybe you got your lib paths wrong...

Ok, I made a fresh install of C:B (using RC2 installed, previously I had downloaded the CVS build version) so it is now installed with the default options. I checked the global linker options and there are no libraries listed [Settings/Compiler/Linker]

All directories ARE pointing to the mingW installation of the NEW C:B
[C:\Program Files\CodeBlocks\Include]
[C:\Program Files\CodeBlocks\lib]

Quote
I have a hunch... do you have defined in your project, WXUSINGDLL  (for compiler)? It seems to try to link to wxwidgets statically...


I defined WXUSINGDLL, didnt needed to use it on DevC++, so I do not know what is its use exactly. I guess it makes my program use wx libs dinamically instead of statically (I prefer the statically linked libraries).

Quote
Other than that, I couldn't tell. Try enabling the "full commandline" on your compiler options so we can help you troubleshoot.

I do not understand this last one, is that "full commandile" an option on the C:B IDE?.
 Anyway, I have tried to se what is the instruction C:B  gives to mingW but none of the windows give me that information.
This is what I got from the "Build Log" after with a Rebuild command:

Project   : Hanjie3D
Compiler  : GNU GCC Compiler (called directly)
Directory : H:\My Documents\Programs\Hanjie3D\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: gui.cpp
Compiling: cube3d.cpp
Compiling: cursor.cpp
Compiling: graphicengine.cpp
Compiling: camera.cpp
Compiling: inputengine.cpp
Compiling: main.cpp
Compiling: scenario.cpp
Compiling: scenario3d.cpp
Linking executable: H:\My Documents\Programs\Hanjie3D\Hanjie3D.exe
C:\Program Files\CodeBlocks\lib/libwx_mswu-2.6.a(monolib_string.o):string.cpp:(.text+0x2b70): multiple definition of `wxString::wxString(char const*, wxMBConv&, unsigned int)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN8wxStringC1EPKcR8wxMBConvj[wxString::wxString(char const*, wxMBConv&, unsigned int)]+0x0): first defined here
..\Hanjie3D\gui.o:gui.cpp:(.text+0x2cf): undefined reference to `wxString::Printf(char const*, ...)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN12wxStringBaseC2EPKcj[wxStringBase::wxStringBase(char const*, unsigned int)]+0x23): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x25): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN8wxString6appendEjc[wxString::append(unsigned int, char)]+0x22): undefined reference to `wxStringBase::append(unsigned int, char)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN12wxStringBase10ConcatSelfEjPKc[wxStringBase::ConcatSelf(unsigned int, char const*)]+0x22): undefined reference to `wxStringBase::ConcatSelf(unsigned int, char const*, unsigned int)'
..\Hanjie3D\gui.o:gui.cpp:(.rdata$_ZTV5MyApp[vtable for MyApp]+0x68): undefined reference to `wxApp::Initialize(int&, char**)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 45 seconds)
0 errors, 0 warnings
 


It is curious that I get "0 errors, 0 warning" huh...

Well, if it is of some use here is the complete .cbp file:

<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_project_file>
<CodeBlocks_project_file>
   <FileVersion major="1" minor="1"/>
   <Project>
      <Option title="Hanjie3D"/>
      <Option makefile="Makefile"/>
      <Option makefile_is_custom="0"/>
      <Option compiler="0"/>
      <Build>
         <Target title="default">
            <Option output="H:\My Documents\Programs\Hanjie3D\Hanjie3D.exe"/>
            <Option working_dir="."/>
            <Option object_output="..\Hanjie3D"/>
            <Option deps_output=".deps"/>
            <Option type="0"/>
            <Option compiler="0"/>
            <Option projectResourceIncludeDirsRelation="0"/>
         </Target>
      </Build>
      <Compiler>
      </Compiler>
      <Linker>
         <Add option="-mthreads"/>
         <Add option="-Wl,--subsystem,windows"/>
         <Add library="SDL_ttf"/>
         <Add library="SDLmain"/>
         <Add library="SDL"/>
         <Add library="mingw32"/>
         <Add library="wx_mswu-2.6"/>
         <Add library="opengl32"/>
         <Add library="glu32"/>
         <Add library="png"/>
         <Add library="z"/>
         <Add library="jpeg"/>
         <Add library="tiff"/>
         <Add library="rpcrt4"/>
         <Add library="oleaut32"/>
         <Add library="ole32"/>
         <Add library="uuid"/>
         <Add library="odbc32"/>
         <Add library="winspool"/>
         <Add library="winmm"/>
         <Add library="shell32"/>
         <Add library="comctl32"/>
         <Add library="comdlg32"/>
         <Add library="ctl3d32"/>
         <Add library="advapi32"/>
         <Add library="wsock32"/>
         <Add library="gdi32"/>
      </Linker>
      <Unit filename="camera.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="camera.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="cube3d.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="cube3d.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="cursor.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="cursor.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="graphicengine.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="graphicengine.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="gui.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="gui.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="inputengine.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="inputengine.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="main.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="main.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="myframe.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="scenario.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="scenario.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="scenario3d.cpp">
         <Option compilerVar="CPP"/>
         <Option target="default"/>
      </Unit>
      <Unit filename="scenario3d.h">
         <Option compilerVar="CPP"/>
         <Option compile="0"/>
         <Option link="0"/>
         <Option target="default"/>
      </Unit>
   </Project>
</CodeBlocks_project_file>


Any hints?
thank you again!

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Problem porting from DevC++ to C:B
« Reply #3 on: November 25, 2005, 06:42:53 pm »
The "Full Commandline" is in Compiler Setting, Other. There's something that says "Compiler Logging:". Normally it says "Task description". Change it to "Full Commandline".

xtracto

  • Guest
Re: Problem porting from DevC++ to C:B
« Reply #4 on: November 25, 2005, 06:58:18 pm »
The "Full Commandline" is in Compiler Setting, Other. There's something that says "Compiler Logging:". Normally it says "Task description". Change it to "Full Commandline".


Done,
this is what I get:
Project   : Hanjie3D
Compiler  : GNU GCC Compiler (called directly)
Directory : H:\My Documents\Programs\Hanjie3D\
--------------------------------------------------------------------------------
Switching to target: default
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c gui.cpp -o ..\Hanjie3D\gui.o
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c cube3d.cpp -o ..\Hanjie3D\cube3d.o
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c cursor.cpp -o ..\Hanjie3D\cursor.o
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c graphicengine.cpp -o ..\Hanjie3D\graphicengine.o
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c camera.cpp -o ..\Hanjie3D\camera.o
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c inputengine.cpp -o ..\Hanjie3D\inputengine.o
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c main.cpp -o ..\Hanjie3D\main.o
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c scenario.cpp -o ..\Hanjie3D\scenario.o
mingw32-g++.exe       -I"C:\Program Files\CodeBlocks\include" -c scenario3d.cpp -o ..\Hanjie3D\scenario3d.o
mingw32-g++.exe    -L"C:\Program Files\CodeBlocks\lib" -o "H:\My Documents\Programs\Hanjie3D\Hanjie3D.exe" ..\Hanjie3D\gui.o ..\Hanjie3D\cube3d.o ..\Hanjie3D\cursor.o ..\Hanjie3D\graphicengine.o ..\Hanjie3D\camera.o ..\Hanjie3D\inputengine.o ..\Hanjie3D\main.o ..\Hanjie3D\scenario.o ..\Hanjie3D\scenario3d.o     -mthreads -Wl,--subsystem,windows    -lSDL_ttf -lSDLmain -lSDL -lmingw32 -lwx_mswu-2.6 -lopengl32 -lglu32 -lpng -lz -ljpeg -lrpcrt4 -loleaut32 -lole32 -luuid -lodbc32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lcomdlg32 -lctl3d32 -ladvapi32 -lwsock32 -lgdi32  -mwindows
C:\Program Files\CodeBlocks\lib/libwx_mswu-2.6.a(monolib_string.o):string.cpp:(.text+0x2b70): multiple definition of `wxString::wxString(char const*, wxMBConv&, unsigned int)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN8wxStringC1EPKcR8wxMBConvj[wxString::wxString(char const*, wxMBConv&, unsigned int)]+0x0): first defined here
..\Hanjie3D\gui.o:gui.cpp:(.text+0x2cf): undefined reference to `wxString::Printf(char const*, ...)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN12wxStringBaseC2EPKcj[wxStringBase::wxStringBase(char const*, unsigned int)]+0x23): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x25): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN8wxString6appendEjc[wxString::append(unsigned int, char)]+0x22): undefined reference to `wxStringBase::append(unsigned int, char)'
..\Hanjie3D\gui.o:gui.cpp:(.text$_ZN12wxStringBase10ConcatSelfEjPKc[wxStringBase::ConcatSelf(unsigned int, char const*)]+0x22): undefined reference to `wxStringBase::ConcatSelf(unsigned int, char const*, unsigned int)'
..\Hanjie3D\gui.o:gui.cpp:(.rdata$_ZTV5MyApp[vtable for MyApp]+0x68): undefined reference to `wxApp::Initialize(int&, char**)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 45 seconds)
0 errors, 0 warnings
 



xtracto

  • Guest
Re: Problem porting from DevC++ to C:B
« Reply #5 on: November 25, 2005, 07:25:01 pm »
Well, so far I haven't been able to fix the problem. Anyway it seems it is a compatibility problem with wxWidgets.

I disabled all the wxWidgets code in my app and it compiled :).

I guess I'll have to use C:B for non-wx code. Anyway it will help me to test how the C:B IDE.

Cheers.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Problem porting from DevC++ to C:B
« Reply #6 on: November 25, 2005, 07:26:29 pm »
Hmmm.... it seems that the compiled files  try to link the library statically. Check if you have WXUSINGDLL In your project's build options, under the "#defines" tab.

Then rebuild.