Author Topic: Linking error with wxWidgets 2.7  (Read 5128 times)

crackerizer

  • Guest
Linking error with wxWidgets 2.7
« on: October 03, 2006, 08:14:34 am »
Hello,
I'm trying to build a very simple program with only a single frame with static library. Everything is fine with manual build. Here are the build commands i use.

Code: cpp
g++ -c -o main.o -mthreads -D__WXMSW__ -D_UNICODE -O2 main.cpp

windres -ixYGx.rc -oxYGx.o --define __WXMSW__ --define _UNICODE

g++ -o xYGxHelper.exe main.o xYGx.o -mthreads -mwindows -lwxmsw27u_core -lwxbase27u -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregexu -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32

But after put the project in C:B workspace and config the options. I get these errors.

Code: cpp
obj\Release\main.o(.text+0x17b):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.text+0x1a3):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.text+0x3ba):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.text+0x672):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.text+0x693):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.rdata$_ZTV10xYGxHelper[vtable for xYGxHelper]+0x44):main.cpp: undefined reference to `wxApp::Initialize(int&, char**)'

Please check my build configuration if there is something i'm missing.

Code: cpp
Compile flag: -Wall -O2 -s
Other options: -mthreads -mwindows
Define:
__WXMSW__
_UNICODE

linking options (sort by order):
-mthreads
-Wl,--subsystem,windows
-mwindows
-lwxmsw27u_core
-lwxbase27u
-lwxtiff
-lwxjpeg
-lwxpng
-lwxzlib
-lwxregexu
-lwxexpat
-lkernel32
-luser32
-lgdi32
-lcomdlg32
-lwinspool
-lwinmm
-lshell32
-lcomctl32
-lole32
-loleaut32
-luuid
-lrpcrt4
-ladvapi32
-lwsock32
-lodbc32

Thank you

Offline rjmyst3

  • Multiple posting newcomer
  • *
  • Posts: 117
    • wxFormBuilder
Re: Linking error with wxWidgets 2.7
« Reply #1 on: October 03, 2006, 01:05:58 pm »
Quote
-lwxmsw27u_core -lwxbase27u
Looks like you are linking to the unicode library.

Quote
wxStringBase::InitWith(char const*,
But you are compiling with non-unicode functions.

Looks like you missed wxUSE_UNICODE in your preprocessor definitions.
Add this:
Code
-DwxUSE_UNICODE

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Linking error with wxWidgets 2.7
« Reply #2 on: October 03, 2006, 01:32:44 pm »
..Looks like you missed wxUSE_UNICODE in your preprocessor definitions.
Add this:
Code
-DwxUSE_UNICODE

this is for shure not the problem, look in wx\platform.h:228-246 how these macros are used

either define UNICODE or _UNICODE or wxUSE_UNICODE=1
if you want to use the unicode wxlibs.

Offline rjmyst3

  • Multiple posting newcomer
  • *
  • Posts: 117
    • wxFormBuilder
Re: Linking error with wxWidgets 2.7
« Reply #3 on: October 03, 2006, 02:28:46 pm »
I stand corrected. Defining wxUSE_UNICODE does nothing - it has to be defined to a value, 0 or 1. Also, any of the UNICODE defines should work equally well, as long as wx/platform.h is included first - which it is by both wx/string.h (through wx/defs.h) and wx/wxchar.h.

However main.o was definitely compiled with wxChar typedef'd as char, which can only happen when wxUSE_UNICODE = 0.

See wx/string.h line 266 for the declaration of InitWith with wxChar, and wx/wxchar.h lines 181 and 182 for the typedef of wxChar.

Rebuild?

crackerizer

  • Guest
Re: Linking error with wxWidgets 2.7
« Reply #4 on: October 03, 2006, 03:53:41 pm »
Thank you for your fast responses.
I tried everything suggested here without luck.
As i stated that the manual build works fine with _UNICODE flag and i've defined it in C:B.
Is there any way i can see the raw build command?
and can this be C:B bug?? i dont see any mistake here. I've tried almost every possible configurations  :(.
« Last Edit: October 03, 2006, 04:04:42 pm by crackerizer »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Linking error with wxWidgets 2.7
« Reply #5 on: October 03, 2006, 04:04:35 pm »
Thank you for your fast responses.
I tried everything suggested here without luck.
As i stated that the manual build works fine with _UNICODE flag and i've defined it in C:B.
Is there any way i can see the raw build command?
   

//-- Full Compile Logging --
   Settings->Compiler and Debugger->"Other"->Compiler logging = "Full command line".

crackerizer

  • Guest
Re: Linking error with wxWidgets 2.7
« Reply #6 on: October 03, 2006, 04:20:09 pm »
Thank you very much. it's SOLVED.

The problem is that there are the old object files in obj/ folder. C:B didn't recompile the source codes when i pressed 'play' button. After rebuild the codes, everything is ok now. Thank you.