User forums > Help
Cannot compile wxwidget 'hello world' [SOLVED]
canassa:
I've been trying without sucess to compile the WxWidgets 'Hello Word' application with C::B. The problem occours at the linking part, this is the output:
Project : Console application
Compiler : GNU GCC Compiler (called directly)
Directory : C:\Projetos\teste03\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.cpp
main.cpp:76:2: warning: no newline at end of file
Linking console executable: C:\Projetos\teste03\console.exe
.objs\main.o(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x27):main.cpp: undefined reference to `_imp___ZN12wxStringBase8InitWithEPKcjj'
.objs\main.o(.rdata$_ZTV5MyApp[vtable for MyApp]+0x68):main.cpp: undefined reference to `wxApp::Initialize(int&, char**)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
2 errors, 1 warnings
I guess I forgot to include a library, but I don't know which one. :?
I don't if this helps, but this is my project file:
<?xml version="1.0"?>
<!DOCTYPE CodeBlocks_project_file>
<CodeBlocks_project_file>
<FileVersion major="1" minor="1"/>
<Project>
<Option title="Console application"/>
<Option makefile="Makefile"/>
<Option makefile_is_custom="0"/>
<Option compiler="0"/>
<Build>
<Target title="default">
<Option output="C:\Projetos\teste03\console.exe"/>
<Option working_dir="."/>
<Option object_output=".objs"/>
<Option deps_output=".deps"/>
<Option type="1"/>
<Option compiler="0"/>
<Option projectResourceIncludeDirsRelation="1"/>
</Target>
</Build>
<Compiler>
<Add option="-DWXUSINGDLL"/>
<Add directory="$(WXWIN)\contrib\include"/>
<Add directory="$(WXWIN)\include"/>
<Add directory="$(WXWIN)\lib\gcc_dll$(WX_CFG)\mswu"/>
</Compiler>
<ResourceCompiler>
<Add directory="$(WXWIN)\contrib\include"/>
</ResourceCompiler>
<Linker>
<Add library="wxmsw26u"/>
<Add directory="$(WXWIN)\lib\gcc_dll"/>
</Linker>
<Unit filename="main.cpp">
<Option compilerVar="CPP"/>
<Option target="default"/>
</Unit>
</Project>
</CodeBlocks_project_file>
Thanks,
Canassa
thomas:
You are linking against an unicode build.
Open Project options, go to compiler tab, and add wxUSE_UNICODE to the #defines field.
canassa:
Thanks, it works now :D
I still had some issues thought. Some conversion from wxString to char* problems, so I had to convert all strings to wxT("string"). The program also couldn't find the wxwidget dll. That's weird because I have it in my PATH... anyway, I just copied it to system32 and everything is working now :)
Thanks again,
Canassa
RedAlert:
I tried simple Helloworld template in C:B and had the same problem with canassa. After adding wxUSE_UNICODE in #define and rebuild, I got the following error:
---
main.cpp:49: error: call of overloaded `wxMenu(const char[1])' is ambiguous
C:/wxWidgets-2.8.0/include/wx/msw/menu.h:118: note: candidates are: wxMenu::wxMenu(const wxMenu&) <near match>
C:/wxWidgets-2.8.0/include/wx/msw/menu.h:55: note: wxMenu::wxMenu(long int) <near match>
C:/wxWidgets-2.8.0/include/wx/msw/menu.h:53: note: wxMenu::wxMenu(const wxString&, long int) <near match>
main.cpp:53: error: call of overloaded `wxMenu(const char[1])' is ambiguous
C:/wxWidgets-2.8.0/include/wx/msw/menu.h:118: note: candidates are: wxMenu::wxMenu(const wxMenu&) <near match>
C:/wxWidgets-2.8.0/include/wx/msw/menu.h:55: note: wxMenu::wxMenu(long int) <near match>
C:/wxWidgets-2.8.0/include/wx/msw/menu.h:53: note: wxMenu::wxMenu(const wxString&, long int) <near match>
Process terminated with status 1 (0 minutes, 8 seconds)
---
Is that C:B didn't realize wxMenu constructors? How do I solve out this problem?
Thank you for reading!
Biplab:
Why don't you use wxWidgets Project Wizard?
It's the most elegant way to start programming with wxWidgets. :)
Please try it, if you haven't used it earlier.
Navigation
[0] Message Index
[#] Next page
Go to full version