Author Topic: wxWidgets app only compile with SHARED=1  (Read 11580 times)

Offline mosfet

  • Multiple posting newcomer
  • *
  • Posts: 23
wxWidgets app only compile with SHARED=1
« on: December 14, 2005, 04:58:49 pm »
Hi,

I have developped a wxWidget(2.6.2) app on Windows XP but I can only link with the shared version.
However I would like to use the static one, how can I do, everything I tried failed.

I have compiled wxWidget both as shared and static and when in linker and compiler option I put

Directories
$(WX_DIR)\lib\gcc_dll\msw
$(WX_DIR)\include
$(WX_DIR)\contrib\include
.\wxdockit\include

linker:
$(WX_DIR)\lib\gcc_dll
.\wxdockit\lib\gcc_dll

it works.

When I replace all the gcc_dll by gcc_lib it failed during linking while gcc_lib exists and holds my static libs.
I don't get it ...

Switching to target: default
Linking executable: SmartTester.exe
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0x99): undefined reference to `_imp__wxNotebookNameStr'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0xe1): undefined reference to `_imp__wxDefaultSize'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0xea): undefined reference to `_imp__wxDefaultPosition'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0x108): undefined reference to `_imp___ZN10wxNotebookC1EP8wxWindowiRK7wxPointRK6wxSizelRK8wxString'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0x1a9): undefined reference to `_imp___ZN16wxDockWindowBase9SetClientEP8wxWindowb'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0x297): undefined reference to `_imp__wxNotebookNameStr'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0x2df): undefined reference to `_imp__wxDefaultSize'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0x2e8): undefined reference to `_imp__wxDefaultPosition'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0x306): undefined reference to `_imp___ZN10wxNotebookC1EP8wxWindowiRK7wxPointRK6wxSizelRK8wxString'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text+0x3a7): undefined reference to `_imp___ZN16wxDockWindowBase9SetClientEP8wxWindowb'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN12wxDockWindowD2Ev[wxDockWindow::~wxDockWindow()]+0xa): undefined reference to `_imp___ZTV12wxDockWindow'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN16wxDockWindowBaseD2Ev[wxDockWindowBase::~wxDockWindowBase()]+0x39): undefined reference to `_imp___ZTV16wxDockWindowBase'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN11wxMiniFrameD2Ev[wxMiniFrame::~wxMiniFrame()]+0xa): undefined reference to `_imp___ZTV11wxMiniFrame'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN11wxMiniFrameD2Ev[wxMiniFrame::~wxMiniFrame()]+0x1a): undefined reference to `_imp___ZN7wxFrameD2Ev'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN12wxMouseEventD1Ev[wxMouseEvent::~wxMouseEvent()]+0xa): undefined reference to `_imp___ZTV12wxMouseEvent'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN7wxEventD2Ev[wxEvent::~wxEvent()]+0xa): undefined reference to `_imp___ZTV7wxEvent'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN8wxObjectD2Ev[wxObject::~wxObject()]+0xa): undefined reference to `_imp___ZTV8wxObject'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN8wxObjectD2Ev[wxObject::~wxObject()]+0x1a): undefined reference to `_imp___ZN8wxObject5UnRefEv'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x7): undefined reference to `_imp___ZN12wxStringBase4nposE'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN12wxStringBaseC2EPKc[wxStringBase::wxStringBase(char const*)]+0x27): undefined reference to `_imp___ZN12wxStringBase8InitWithEPKcjj'
.objs\MsgDockBar.o:MsgDockBar.cpp:(.text$_ZN12wxDockWindowC2EP8wxWindowiRK8wxStringRK7wxPointRK6wxSizeS4_j[wxDockWindow::wxDockWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, wxString const&, unsigned int)]+0x4b): undefined reference to `_imp___ZTV12wxDockWindow'
...



Is there a mean under windows to see exactly with what parameters gcc is called ?
« Last Edit: December 14, 2005, 05:25:45 pm by mosfet »

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: wxWidgets app only compile with SHARED=1
« Reply #1 on: December 14, 2005, 05:38:02 pm »
Is there a mean under windows to see exactly with what parameters gcc is called ?

Settings -> Compiler -> Other -> set "Compiler logging" to "Full command line"

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: wxWidgets app only compile with SHARED=1
« Reply #2 on: December 14, 2005, 06:17:17 pm »
which version of codeblocks are you using ? ( a recent SVN build    or    1.0RC2 )

if you have a recent SVN build of CB, you can use the following project file, which builds static wx-apps fine
you just have to edit the global variable WX  (add Base directory)

Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
    <FileVersion major="1" minor="2" />
    <Project>
        <Option title="wx static" />
        <Option pch_mode="0" />
        <Option compiler="0" />
        <Build>
            <Target title="default">
                <Option output="wxwidgets_static.exe" />
                <Option type="0" />
                <Option compiler="0" />
                <Option includeInTargetAll="1" />
                <Option projectResourceIncludeDirsRelation="0" />
            </Target>
            <Environment>
                <Variable name="WX_CFG" value="" />
            </Environment>
        </Build>
        <Compiler>
            <Add option="-pipe" />
            <Add option="-mthreads" />
            <Add option="-Winvalid-pch" />
            <Add option='-include &quot;wx_pch.h&quot;' />
            <Add option="-D__GNUWIN32__" />
            <Add option="-D__WXMSW__" />
            <Add option="-DUSE_PCH" />
            <Add directory="$(#WX.include)" />
            <Add directory="$(#WX.lib)\gcc_lib$(WX_CFG)\msw" />
            <Add directory="$(#WX)\contrib\include" />
        </Compiler>
        <ResourceCompiler>
            <Add directory="$(#WX.include)" />
        </ResourceCompiler>
        <Linker>
            <Add library="wxmsw26" />
            <Add library="winspool" />
            <Add library="winmm" />
            <Add library="shell32" />
            <Add library="comctl32" />
            <Add library="ctl3d32" />
            <Add library="odbc32" />
            <Add library="advapi32" />
            <Add library="wsock32" />
            <Add library="opengl32" />
            <Add library="glu32" />
            <Add library="ole32" />
            <Add library="oleaut32" />
            <Add library="uuid" />
            <Add directory="$(#WX.lib)\gcc_lib$(WX_CFG)" />
            <Add directory="$(#WX.lib)" />
        </Linker>
        <Unit filename="main.cpp">
            <Option compilerVar="CPP" />
            <Option target="default" />
        </Unit>
        <Unit filename="main.h">
            <Option compilerVar="" />
            <Option compile="0" />
            <Option link="0" />
            <Option target="default" />
        </Unit>
        <Unit filename="wx_pch.h">
            <Option compilerVar="" />
            <Option compile="0" />
            <Option link="0" />
            <Option target="default" />
        </Unit>
        <Unit filename="wx_pch.h">
            <Option compilerVar="CPP" />
            <Option link="0" />
            <Option weight="0" />
            <Option target="default" />
        </Unit>
    </Project>
</CodeBlocks_project_file>

Offline mosfet

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: wxWidgets app only compile with SHARED=1
« Reply #3 on: December 14, 2005, 06:50:38 pm »
I have Codeblocks 1.0RC2 because I never managed to compiled a SVN version.
But I didin't see in Cb 1.0RC2 that I could specify wxWidgets as a static lib.
However it assumes that wxWidget has been compiled as a monolithic lib and it's not always the case.
Developers should ask user to indicate how was compiled wxwidgets (shared | monolithic).
Maybe they should add in Project Options :

Using wxWidgets DLL NoMonolithic
Using wxWidgets DLL Monolithic
Using wxWidgets static NoMonoLithic
Using wxWidgets static MonoLithic

which version of codeblocks are you using ? ( a recent SVN build    or    1.0RC2 )

if you have a recent SVN build of CB, you can use the following project file, which builds static wx-apps fine
you just have to edit the global variable WX  (add Base directory)

Code
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
    <FileVersion major="1" minor="2" />
    <Project>
        <Option title="wx static" />
        <Option pch_mode="0" />
        <Option compiler="0" />
        <Build>
            <Target title="default">
                <Option output="wxwidgets_static.exe" />
                <Option type="0" />
                <Option compiler="0" />
                <Option includeInTargetAll="1" />
                <Option projectResourceIncludeDirsRelation="0" />
            </Target>
            <Environment>
                <Variable name="WX_CFG" value="" />
            </Environment>
        </Build>
        <Compiler>
            <Add option="-pipe" />
            <Add option="-mthreads" />
            <Add option="-Winvalid-pch" />
            <Add option='-include &quot;wx_pch.h&quot;' />
            <Add option="-D__GNUWIN32__" />
            <Add option="-D__WXMSW__" />
            <Add option="-DUSE_PCH" />
            <Add directory="$(#WX.include)" />
            <Add directory="$(#WX.lib)\gcc_lib$(WX_CFG)\msw" />
            <Add directory="$(#WX)\contrib\include" />
        </Compiler>
        <ResourceCompiler>
            <Add directory="$(#WX.include)" />
        </ResourceCompiler>
        <Linker>
            <Add library="wxmsw26" />
            <Add library="winspool" />
            <Add library="winmm" />
            <Add library="shell32" />
            <Add library="comctl32" />
            <Add library="ctl3d32" />
            <Add library="odbc32" />
            <Add library="advapi32" />
            <Add library="wsock32" />
            <Add library="opengl32" />
            <Add library="glu32" />
            <Add library="ole32" />
            <Add library="oleaut32" />
            <Add library="uuid" />
            <Add directory="$(#WX.lib)\gcc_lib$(WX_CFG)" />
            <Add directory="$(#WX.lib)" />
        </Linker>
        <Unit filename="main.cpp">
            <Option compilerVar="CPP" />
            <Option target="default" />
        </Unit>
        <Unit filename="main.h">
            <Option compilerVar="" />
            <Option compile="0" />
            <Option link="0" />
            <Option target="default" />
        </Unit>
        <Unit filename="wx_pch.h">
            <Option compilerVar="" />
            <Option compile="0" />
            <Option link="0" />
            <Option target="default" />
        </Unit>
        <Unit filename="wx_pch.h">
            <Option compilerVar="CPP" />
            <Option link="0" />
            <Option weight="0" />
            <Option target="default" />
        </Unit>
    </Project>
</CodeBlocks_project_file>

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: wxWidgets app only compile with SHARED=1
« Reply #4 on: December 14, 2005, 06:56:05 pm »
I have Codeblocks 1.0RC2 because I never managed to compiled a SVN version.

You can get an already SVN compiled version from Therion.

But I didin't see in Cb 1.0RC2 that I could specify wxWidgets as a static lib.

AFAIK, you should add the needed libraries to the linker. I do not think that there is a special option for that.

Michael

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: wxWidgets app only compile with SHARED=1
« Reply #5 on: December 14, 2005, 06:58:33 pm »
I have Codeblocks 1.0RC2 because I never managed to compiled a SVN version.
you can download one here http://paginas.terra.com.br/informatica/mauricio/codeblocks/
Quote
But I didin't see in Cb 1.0RC2 that I could specify wxWidgets as a static lib.
However it assumes that wxWidget has been compiled as a monolithic lib and it's not always the case.
Developers should ask user to indicate how was compiled wxwidgets (shared | monolithic).
that's left to you as homework  :) and when you've managed it - save it as user-template

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: wxWidgets app only compile with SHARED=1
« Reply #6 on: December 14, 2005, 07:01:02 pm »
But I didin't see in Cb 1.0RC2 that I could specify wxWidgets as a static lib.
AFAIK, you should add the needed libraries to the linker. I do not think that there is a special option for that.
but that's the tricky part! better go with MONOLITHIC wxwidgets version

[edit]
« Last Edit: December 14, 2005, 07:02:34 pm by tiwag »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: wxWidgets app only compile with SHARED=1
« Reply #7 on: December 14, 2005, 07:09:22 pm »
but that's the tricky part! better go with MONOLITHIC wxwidgets version

MONOLITHIC is easier to build and handle (I use it myself for those reasons :)), but if you do not need all the wxWidgets functionalities and/or is the lib size a constraint, then better build just the needed libraries.

Michael

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Re: wxWidgets app only compile with SHARED=1
« Reply #8 on: December 15, 2005, 10:16:53 am »
but that's the tricky part! better go with MONOLITHIC wxwidgets version

MONOLITHIC is easier to build and handle (I use it myself for those reasons :)), but if you do not need all the wxWidgets functionalities and/or is the lib size a constraint, then better build just the needed libraries.
I tried this last week, but I had to include all the libraries before I was able to compile anything... :?
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: wxWidgets app only compile with SHARED=1
« Reply #9 on: December 15, 2005, 10:34:15 am »
... but I had to include all the libraries before I was able to compile anything... :?
that's exactly with what it results at last.

the only example where i managed to use the non-monolithic version of wxwidgets reasonably was,
when i built console applications using wxBase only without any GUI stuff.

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: wxWidgets app only compile with SHARED=1
« Reply #10 on: December 15, 2005, 11:44:56 am »
... but I had to include all the libraries before I was able to compile anything... :?
that's exactly with what it results at last.

the only example where i managed to use the non-monolithic version of wxwidgets reasonably was,
when i built console applications using wxBase only without any GUI stuff.

That's interesting to know. In my idea was to use monolithic to understand how wxWidgets works and then use a non-monolithic version of it for development...But it seems not to be possible or quite :?.

Michael