App built with static lib needs dlls (windows 7)

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
RobertSimpson
Experienced Solver
Experienced Solver
Posts: 85
Joined: Sat Oct 18, 2008 8:32 pm

App built with static lib needs dlls (windows 7)

Postby RobertSimpson » Mon Nov 12, 2018 3:59 pm

I have an app which is compiling and running fine under windows 7, 10 (MSVC), Ubuntu 1804 and windows 10 (msys2, gcc). I am now trying to get it to run in windows 7 using msys2 (Eclipse/msys2/gcc). It compiles ok but won't run and it's asking for the following dlls:

Code: Select all

wxbase311u_gcc_custom.dll
wxmsw311u_core_gcc_custom.dll
wxmsw311u_gl_gcc_custom.dll


(Note it only asks for one of these at a time. I've been copying the dll into the .exe directory and running again to get the next one and so on.)

With all the dlls in the .exe directory, it runs but with problems. I'm getting a lot of assertions about mouse capture and it eventually hangs because it displays a dialog box underneath other windws which makes it inaccessible.

I do have both static and dynamic wx:

Code: Select all

./mingw64/lib/wx/include/msw-unicode-3.1/wx
./mingw64/lib/wx/include/msw-unicode-static-3.1/wx


I'm not familiar with the intricacies of dlls but I'm assuming the way to select the static libraries is to include the 'static' version of the library e.g.

Code: Select all

g++ -std=c++1y -std=c++17 -I../../ -I"/msys64/include/wx-3.1" -I"/msys64/lib/wx/include/msw-unicode-static-3.1" -O0 -g3 -Wall -c -fmessage-length=0 `wx-config --cxxflags` -MMD -MP -MF"context_menu.d" -MT"context_menu.o" -o "context_menu.o" "../context_menu.cpp"


wx-config gives:

Code: Select all

$ wx-config --cxxflags
-I/mingw64/lib/wx/include/msw-unicode-static-3.1 -I/mingw64/include/wx-3.1 -D_FILE_OFFSET_BITS=64 -D__WXMSW__

$ wx-config --libs
-L/mingw64/lib   -Wl,--subsystem,windows -mwindows /mingw64/lib/libwx_mswu_xrc-3.1.a /mingw64/lib/libwx_mswu_qa-3.1.a /mingw64/lib/libwx_baseu_net-3.1.a /mingw64/lib/libwx_mswu_html-3.1.a /mingw64/lib/libwx_mswu_adv-3.1.a /mingw64/lib/libwx_mswu_core-3.1.a /mingw64/lib/libwx_baseu_xml-3.1.a /mingw64/lib/libwx_baseu-3.1.a -llzma -lwxtiff-3.1 -lwxjpeg-3.1 -lwxpng-3.1 -lwxregexu-3.1 -lwxscintilla-3.1 -lexpat -lz -lrpcrt4 -loleaut32 -lole32 -luuid -luxtheme -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lcomdlg32 -ladvapi32 -lversion -lwsock32 -lgdi32 -loleacc


Any hints as to the next step?

I was expecting a port from windows 10/msys to windows 7/msys to be trivial but it's complicated by the fact that Eclipse loses a lot of important settings (e.g. the toolchain settings and command line pattern) when moving from one system to another so it's entirely possible I have one of them wrong. Also there appears to be a difference in the way Eclipse handles paths in windows 7 and windows 10 e.g. the include files have to be specified as /msys64/lib/... rather than /usr/lib/...

System:
    Windows 7 professional
    wxWidgets 3.1.1
    Eclipse Version: 2018-09 (4.9.0) Build id: 20180917-1800
    gcc 8.2

catalin
Moderator
Moderator
Posts: 1480
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: App built with static lib needs dlls (windows 7)

Postby catalin » Tue Nov 13, 2018 1:03 pm

When it needs the wx dll-s, obviously the app was built using dynamic libs, even if you intended otherwise.

I can't help with setting up Eclipse, but
the way to select the static libraries is to include the 'static' version of the library e.g. [...] -I"/msys64/lib/wx/include/msw-unicode-static-3.1"
is the wrong assumption. "-I" precedes an include path; it has nothing to do with the build type. More than that: the compilation command that you showed is for compiling a file, not for linking objects in a static or dynamic lib, which would have (or need) a relevant linker option.

RobertSimpson
Experienced Solver
Experienced Solver
Posts: 85
Joined: Sat Oct 18, 2008 8:32 pm

Re: App built with static lib needs dlls (windows 7)

Postby RobertSimpson » Wed Nov 14, 2018 5:12 am

Ah you're right. I posted the wrong thing. Below is *my* library, not wx despite the name. It's a static libe because it's a .a file, not a .so file.

Code: Select all

Building target: libopengl-wx.a
Invoking: GCC Archiver
ar -r  "libopengl-wx.a"  ./gl-canvas-wx.o ./gl-extensions.o ./gl-font.o ./gl-graph.o ./gl-graph2dwnd.o ./gl-object.o ./gl-shader.o   
C:\msys64\mingw64\bin\ar.exe: creating libopengl-wx.a
Finished building target: libopengl-wx.a


The linker command is still the right one though and I'm now puzzled how you're supposed to select between static and dynamic libaries in wx given that there's only one wx-config command. (I did once know how to compile and use .so files with gcc but it was a long time ago and I don't recall the details. I wasn't intending to use shared libraries at all.)

catalin
Moderator
Moderator
Posts: 1480
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: App built with static lib needs dlls (windows 7)

Postby catalin » Wed Nov 14, 2018 8:40 am

IIUC wx-config is supposed to tell you what wxW builds are available on your system. Does it find both static and dynamic builds?

If you don't have the dll build of wxW, you need to build it yourself or install some already built libs. Building the libs is documented.
Then for choosing the build that you want, I guess it depends on the tools that you use. But in the end it will all resume to the correct use of "-L/path/to/libs" and "-lfilewithoutextention" linker options.

RobertSimpson
Experienced Solver
Experienced Solver
Posts: 85
Joined: Sat Oct 18, 2008 8:32 pm

Re: App built with static lib needs dlls (windows 7)

Postby RobertSimpson » Thu Nov 15, 2018 1:42 am

I couldn't figure out how to use the query options to list all the configs but I did find the default config:

Code: Select all

$ wx-config --selected-config
msw-unicode-static-3.1


I've installed (built from source) both the default (dynamic) and static versions of wx. I only installed the dynamic version by mistake because I forgot the --disable-shared option. Btw, there's a lot of incorrect documentation on the use of the configure script. e.g you really do need the --enable-debug option if you want to see what's going on in the wx libs.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 2834
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: App built with static lib needs dlls (windows 7)

Postby ONEEYEMAN » Thu Nov 15, 2018 3:40 pm

Hi,
An option "--enable-debug" is, always was and always will be an indication of the debug build of the library, i.e. the resulting dll/so/dylib/a files will contain symbols.

The only difference is that on Windows you are linking on the different CRTs with debug vs release (at least with MSVC, don't know about MinGW).

So, where the documentation is wrong?

Thank you.


Return to “Compiler / Linking / IDE Related”

Who is online

Users browsing this forum: No registered users and 2 guests