Author Topic: Cross Linking of a Linux Project in Windows  (Read 8314 times)

Offline apaeffgen

  • Single posting newcomer
  • *
  • Posts: 4
Cross Linking of a Linux Project in Windows
« on: October 12, 2008, 08:28:52 pm »
Hi all,
i am new to Codeblocks /wxWidgets. So maybe the problem is trivial.

On a samba share i have set up a linux CodeBlocks project on Centos, tested some gui-features and build the project for Linux. No Problems so far.

When i open the same project with codeblocks on Windows i get some linker errors.
I use Codeblocks with the mingw included, wxpack and the same project-settings as in the windows example project, that builds without errors.

The build-errors in the error log:
auto-import)

Info: resolving wxAppConsole::ms_appInitFn        by linking to __imp___ZN12wxAppConsole12ms_appInitFnE (auto-import)

C:\Programme\CodeBlocks\MinGW\bin\ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.

This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.obj\Debug\Windows2Main.o: In function `_ZNK12wxWindowBase10GetMinSizeEv':

C:/wxWidgetsPack/include/wx/window.h:(.text$_ZN12wxStringBase10ConcatSelfEjPKc[wxStringBase::ConcatSelf(unsigned int, char const*)]+0x22): undefined reference to `wxStringBase::ConcatSelf(unsigned int, char const*, unsigned int)'

C:/wxWidgetsPack/include/wx/window.h:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x25): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'

C:/wxWidgetsPack/include/wx/window.h:(.text$_ZN12wxStringBaseC2ERKS_[wxStringBase::wxStringBase(wxStringBase const&)]+0x47): undefined reference to `wxOnAssert(char const*, int, char const*, char const*, char const*)'

obj\Debug\Windows2App.o: In function `_ZN12wxEvtHandler12TryValidatorER7wxEvent':

C:/wxWidgetsPack/include/wx/app.h:(.rdata$_ZTV11Windows2App[vtable for Windows2App]+0x44): undefined reference to `wxApp::Initialize(int&, char**)'

C:/wxWidgetsPack/include/wx/app.h:(.rdata$_ZTV11Windows2App[vtable for Windows2App]+0x90): undefined reference to `wxAppConsole::OnAssertFailure(char const*, int, char const*, char const*, char const*)'

C:/wxWidgetsPack/include/wx/app.h:(.rdata$_ZTV11Windows2App[vtable for Windows2App]+0x94): undefined reference to `wxAppConsole::OnAssert(char const*, int, char const*, char const*)'

collect2: ld returned 1 exit status

Only the linker has some problems.

The System Specs:
WinXP Home SP3
Codeblocks 8.02 with bundled mingw
wxpack for wxWidgets 2.8.8
On Linux Codeblocks 8.02
wxWidgets 2.8.8

P.S. if i forgot relevant info, please excuse me as a newbie.

Thanks in advance for the help
Andreas

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: Cross Linking of a Linux Project in Windows
« Reply #1 on: October 12, 2008, 08:52:13 pm »
Are you trying to link object files compiled without wxUNICODE #defined with a Unicode build of wxWidgets?
http://tdm-gcc.tdragon.net/ - TDM-GCC compiler suite for Windows (GCC 5.1.0 2015-06-28, 32/64-bit, no extra DLLs)

Offline apaeffgen

  • Single posting newcomer
  • *
  • Posts: 4
Re: Cross Linking of a Linux Project in Windows
« Reply #2 on: October 12, 2008, 09:21:43 pm »
Hi TDragon,
i forgot that. Sorry.
The log now says:
Info: resolving vtable for wxwxMenuItemListNodeby linking to __imp___ZTV20wxwxMenuItemListNode (auto-import)
Info: resolving wxAppConsole::ms_appInstance        by linking to __imp___ZN12wxAppConsole14ms_appInstanceE (auto-import)
Info: resolving wxAppConsole::ms_appInitFn        by linking to __imp___ZN12wxAppConsole12ms_appInitFnE (auto-import)
C:\Programme\CodeBlocks\MinGW\bin\ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.obj\Debug\Windows2Main.o: In function `_ZNK12wxWindowBase10GetMaxSizeEv':
C:/wxWidgetsPack/include/wx/window.h:(.text$_ZN12wxStringBase10ConcatSelfEjPKc[wxStringBase::ConcatSelf(unsigned int, char const*)]+0x22): undefined reference to `wxStringBase::ConcatSelf(unsigned int, char const*, unsigned int)'
C:/wxWidgetsPack/include/wx/window.h:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x25): undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Debug\Windows2App.o: In function `_ZN12wxEvtHandler12TryValidatorER7wxEvent':
C:/wxWidgetsPack/include/wx/app.h:(.rdata$_ZTV11Windows2App[vtable for Windows2App]+0x44): undefined reference to `wxApp::Initialize(int&, char**)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 11 seconds)
3 errors, 1 warnings

Any other hints?
And thanks for the usefull tipp.
Best regards
Andreas

Offline TDragon

  • Lives here!
  • ****
  • Posts: 936
    • Twilight Dragon Media
Re: Cross Linking of a Linux Project in Windows
« Reply #3 on: October 12, 2008, 09:43:46 pm »
Actually, I should've said "wxUSE_UNICODE" (note the USE_).
http://tdm-gcc.tdragon.net/ - TDM-GCC compiler suite for Windows (GCC 5.1.0 2015-06-28, 32/64-bit, no extra DLLs)

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Cross Linking of a Linux Project in Windows
« Reply #4 on: October 12, 2008, 09:45:25 pm »
Did you clean the project tree before compiling, or do you use another target for building on win ?

I don't know what happens if you try to link object-files built on linux with the MinGW linker

Offline apaeffgen

  • Single posting newcomer
  • *
  • Posts: 4
Re: Cross Linking of a Linux Project in Windows
« Reply #5 on: October 12, 2008, 10:25:21 pm »
@TDragon:
Thanks, the project is now building.
@Jens:
I use the same target, but cleaned up the project.

The app crashes with an error "....could not be initialized (0xc0000005)....."
I will set up a separate target and try to build it again.

Thanks for the help.
Best regards
Andreas

Offline apaeffgen

  • Single posting newcomer
  • *
  • Posts: 4
Re: Cross Linking of a Linux Project in Windows
« Reply #6 on: October 15, 2008, 02:04:36 pm »
I found the cause of the crashing app.

Even though the app build on windows, the complete project settings were wrong.

At the moment i edited the project-file by hand, setting up targets for the different platforms. The automated project wizard-script puts general compiler, linker... settings not in the target section but below.

I moved and merged all the abstract compiler, linker... settings to special target sections and now the project builds on linux + windows without changing anything.

I set up a user template to reflect the basic settings.
Maybe it would be great to build a cross-platform wxwidgets wizard to simplify building a rudimentary app on every platform (Instead of Debug / Release maybe Platform -> Debug / Release?)

I did not find anything about this topic in the wiki, so maybe it should be added? Maybe as a basic How-To?

Best regards
Andreas

Offline ChiPnGo

  • Single posting newcomer
  • *
  • Posts: 3
Re: Cross Linking of a Linux Project in Windows
« Reply #7 on: December 18, 2008, 06:55:59 pm »
Hi all, I have the same problem:

...

The app crashes with an error "....could not be initialized (0xc0000005)....."

...

What was the solution?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: Cross Linking of a Linux Project in Windows
« Reply #8 on: December 18, 2008, 10:14:56 pm »
Hi all, I have the same problem:

...

The app crashes with an error "....could not be initialized (0xc0000005)....."

...

What was the solution?

I traced my last cause of this problem to an wrong strip.exe being in the system path before the right one.
http://forums.codeblocks.org/index.php/topic,8675.0.html
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org