Author Topic: [SOLVED] C::B 13.12 -static not working  (Read 18871 times)

dcbdbis

  • Guest
[SOLVED] C::B 13.12 -static not working
« on: August 05, 2014, 08:44:20 pm »
Good Morning All,

I have haunted this site, the GNU-GCC site, and other google/yahoo search results. I am using C:B 13.12 with the included MinGW suite under Windows -7. The wxWidgets lib (2.8.12) has been built from scratch following the article on the C::B wiki. The flags for the wxWidgets build was per the C::B wiki article found here: http://wiki.codeblocks.org/index.php?title=WxWindowsQuickRef. I did alter the flags, the flags I built with were: mingw32-make -f makefile.gcc BUILD=release SHARED=1 MONOLITHIC=1 UNICODE=0 CXXFLAGS=-fno-keep-inline-dllexport where I changed the Unicode flag to "0".

I also use FreeBSD and have a second drive where I dual-boot Windows-7 for developing Windows ports. Under FreeBSD I am having no issues of any kind. C::B operates perfectly. It is a great RAD environment. Windows however is causing me issues. Under Windows, I cannot obtain a statically linked .exe file. This is where my problem comes in. The resulting executable still requires the custom dll file to run. They run fine in debug and release builds as long as this dll is in the respective debug and release folders....But I want a static link.

In my linker settings I have "C:\wxWidgets-2.8.12\lib\gcc_dll\libwxmsw28.a" for Windows (minus the quotation marks) and then in the Other Linker Options I have "-static" (minus the quotes). I am building ANSI code, not unicode under Windows.

I've found multiple posts about reading the GCC docs. I have done so for the last 4 days. "-static" is supposed to result in a static link for GCC based compilers. It isn't in my case.

I am suspecting that I am putting the "-static" flag in the wrong location under C::B.

Can someone please enlighten me where to pass the "-static" flag to the linker if not where it is already?

And if I am configured properly....can someone assist in a workaround so I can generate statically linked exe's under Windows?

Also, if I am configured improperly....can someone please post an exact "HowTo" guide to configure C::B for static linking under Windows-7? I ask for the "HowTo" if I am configured improperly because there are no clear, succinct answers in the searches that I have conducted here, and elsewhere. So we might as well post it to prevent more posts like mine about static linking.

If I have missed this post somehow in my searches, I apologize, and would simply appreciate a link to the relevant post(s) for configuring C::B for static linking under WIndows-7.


Thank you for any assistance.


Sincerely and respectfully,

Dave


Edit: In reviewing the build messages. I can see the "-static" flag being passed.

I am building the same app under FreeBSD, Linux, Windows, and then a java version for web deployment for a client of mine. C::B under FreeBSD/Linux is working perfectly. My issue is specific to using C::B under native Windows-7.
« Last Edit: August 08, 2014, 02:15:02 am by dcbdbis »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: C::B 13.12 -static not working
« Reply #1 on: August 05, 2014, 10:05:19 pm »
What custom dll file to run are you talking about?
Post the filename!

If you mean the wxWidgets DLL, you need to have a static wxWidgets library to link to it.

Shared=1 means build DLL.

Tim S.
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

dcbdbis

  • Guest
Re: C::B 13.12 -static not working
« Reply #2 on: August 05, 2014, 10:20:50 pm »
Thank you for your reply.

I do understand what the shared flag means. When I built with "SHARED=0", and since "-static" isn't working, I was unable to debug the source code ported over from FreeBSD. So I rebuilt the libraries with the "SHARED=1" flag so I could at least work.

The dll file that has to be in my "\bin\debug" and "\bin\release" folders to run the code is named "wxmsw28_gcc_custom.dll"

If I can solve the "-static" problem...I will rebuild the libraries with "SHARED=0".


Thank you for your assistance,


Sincerely and respectfully,

Dave

PS: Old Fart here. Been coding since 1973. 1st code and subsequent code for 15 years was written in assembler.  The early Building Automation Systems I supported, were all done in assembler. (motorola 8-bit CPU's)
When I got started....Think ENIAC and 150 baud acoustically coupled modems is how I cut my programming teeth. Green Punch cards.... I am not new to coding, I am relatively new to the C::B IDE/RAD.

ToApolytoXaos

  • Guest
Re: C::B 13.12 -static not working
« Reply #3 on: August 05, 2014, 11:36:38 pm »
I would suggest doing what I did and have found my peace for good.

I have downloaded the following file wxBuild_wxWidgets, tweaked it a bit to point to MinGW (TDM's GCC to be more precise), and compiled my wxMSW-2.8.12 just fine.

dcbdbis

  • Guest
Re: C::B 13.12 -static not working
« Reply #4 on: August 05, 2014, 11:42:17 pm »
Dear ToApolytoXaos,

Thank you for your reply,

I have compiled wxWidgets just fine. It's not a wxWidgets issue. It's where/how to tell C::B to statically link my "libwxmsw28.a" into my project, other than the "-static" flag which I am already passing to C::B.

Thanks anyway though.


Sincerely and respectfully,

Dave

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: C::B 13.12 -static not working
« Reply #5 on: August 05, 2014, 11:59:18 pm »
If you tell the MinGW GCC to link to a DLL how to you expect it NOT to need that DLL!

Code: [Select]
"C:\wxWidgets-2.8.12\lib\gcc_dll\libwxmsw28.a"
Tim S.
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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: C::B 13.12 -static not working
« Reply #6 on: August 06, 2014, 12:02:21 am »
If you want anymore replies I suggest posting a full re-build log.
Maybe it will show you the issue is user error.

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F

Tim S.
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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: C::B 13.12 -static not working
« Reply #7 on: August 06, 2014, 12:07:27 am »
This folder ONLY holds DLL related files C:\wxWidgets-2.8.12\lib\gcc_dll
Try seeing if you have C:\wxWidgets-2.8.12\lib\gcc_lib folder it should hold static files.

Tim S.
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

dcbdbis

  • Guest
Re: C::B 13.12 -static not working
« Reply #8 on: August 06, 2014, 12:09:15 am »
Good Idea!,


Here is is
Code: [Select]
-------------- Clean: Release in BicycleGearingCalculator (compiler: GNU GCC Compiler)---------------

Cleaned "BicycleGearingCalculator - Release"

-------------- Build: Release in BicycleGearingCalculator (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -O2 -IC:\wxWidgets-2.8.12\include -IC:\wxWidgets-2.8.12\lib\gcc_dll\msw -c C:\Users\Dave\workspace\CodeBlocks-Projects\BicycleGearingCalculator\BicycleGearingCalculatorApp.cpp -o obj\Release\BicycleGearingCalculatorApp.o
mingw32-g++.exe -O2 -IC:\wxWidgets-2.8.12\include -IC:\wxWidgets-2.8.12\lib\gcc_dll\msw -c C:\Users\Dave\workspace\CodeBlocks-Projects\BicycleGearingCalculator\BicycleGearingCalculatorMain.cpp -o obj\Release\BicycleGearingCalculatorMain.o
mingw32-g++.exe  -o bin\Release\BicycleGearingCalculator.exe obj\Release\BicycleGearingCalculatorApp.o obj\Release\BicycleGearingCalculatorMain.o  -s -static  C:\wxWidgets-2.8.12\lib\gcc_dll\libwxmsw28.a -mwindows
Output file is bin\Release\BicycleGearingCalculator.exe with size 188.00 KB
Process terminated with status 0 (0 minute(s), 3 second(s))
0 error(s), 0 warning(s) (0 minute(s), 3 second(s))
 

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: C::B 13.12 -static not working
« Reply #9 on: August 06, 2014, 12:12:53 am »
Good Idea!,


Here is is
Code: [Select]
-------------- Clean: Release in BicycleGearingCalculator (compiler: GNU GCC Compiler)---------------

Cleaned "BicycleGearingCalculator - Release"

-------------- Build: Release in BicycleGearingCalculator (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -O2 -IC:\wxWidgets-2.8.12\include -IC:\wxWidgets-2.8.12\lib\gcc_dll\msw -c C:\Users\Dave\workspace\CodeBlocks-Projects\BicycleGearingCalculator\BicycleGearingCalculatorApp.cpp -o obj\Release\BicycleGearingCalculatorApp.o
mingw32-g++.exe -O2 -IC:\wxWidgets-2.8.12\include -IC:\wxWidgets-2.8.12\lib\gcc_dll\msw -c C:\Users\Dave\workspace\CodeBlocks-Projects\BicycleGearingCalculator\BicycleGearingCalculatorMain.cpp -o obj\Release\BicycleGearingCalculatorMain.o
mingw32-g++.exe  -o bin\Release\BicycleGearingCalculator.exe obj\Release\BicycleGearingCalculatorApp.o obj\Release\BicycleGearingCalculatorMain.o  -s -static  C:\wxWidgets-2.8.12\lib\gcc_dll\libwxmsw28.a -mwindows
Output file is bin\Release\BicycleGearingCalculator.exe with size 188.00 KB
Process terminated with status 0 (0 minute(s), 3 second(s))
0 error(s), 0 warning(s) (0 minute(s), 3 second(s))
 

So work on fixing this "gcc_dll" to the proper value of "gcc_lib".

Tim S.
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

dcbdbis

  • Guest
Re: C::B 13.12 -static not working
« Reply #10 on: August 06, 2014, 12:50:14 am »
So I cleaned, then rebuilt the library with the SHARED=0 and UNICODE=0 options with monolithic remaining set at 1. Now I have a gcc_lib subdir.

I modified my project to use the new libwx* file as an external dependency, and made the appropriate changes to the linker settings.

The build is now failing with:

Code: [Select]
||=== Build: Release in BicycleGearingCalculator (compiler: GNU GCC Compiler) ===|
C:\wxWidgets-2.8.12\lib\gcc_lib\libwxmsw28.a(monolib_app.o):app.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-2.8.12\lib\gcc_lib\libwxmsw28.a(monolib_app.o):app.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-2.8.12\lib\gcc_lib\libwxmsw28.a(monolib_app.o):app.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-2.8.12\lib\gcc_lib\libwxmsw28.a(monolib_msw_spinbutt.o):spinbutt.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-2.8.12\lib\gcc_lib\libwxmsw28.a(monolib_filename.o):filename.cpp|| undefined reference to `[email protected]'|
C:\wxWidgets-2.8.12\lib\gcc_lib\libwxmsw28.a(monolib_filename.o):filename.cpp|| undefined reference to `IID_IPersistFile'|

I assumed that since the wxWidget compilation would include these Windows controls as it did when it built the dll. Clearly I am wrong, and C::B is missing something...Likely obvious as I don't do a lot of Windows coding...Mainly Linux and FreeBSD for my clients.

My build string (after cleaning of course) was: mingw32-make -f makefile.gcc BUILD=release SHARED=0 MONOLITHIC=1 UNICODE=0

So then out of growing frustration, I included all the libs.....and it still fails with the above messages.


Hope this info helps....


Sincerely and respectfully,

Dave

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: C::B 13.12 -static not working
« Reply #11 on: August 06, 2014, 02:12:15 am »
I suggest posting the info on the wxForum for better help; note, you will have to post the full re-build log!

http://forums.wxwidgets.org/

You are missing a library; likely more than one.

Edit: http://forums.wxwidgets.org/viewtopic.php?f=19&t=36825

Tim S.
« Last Edit: August 06, 2014, 02:18:50 am by stahta01 »
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

dcbdbis

  • Guest
Re: C::B 13.12 -static not working
« Reply #12 on: August 06, 2014, 02:55:09 am »
OK. Thank you for the pointer.

I would ask this: In my original post...had I setup C::B properly to statically link? The answer to that question will satisfy me that I have setup C::B properly.


Thank you!

Sincerely and respectfully,

Dave

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6666
    • My Best Post
Re: C::B 13.12 -static not working
« Reply #13 on: August 06, 2014, 03:42:13 am »
If static option displays in the build log in the correct location you likely did it right.

What it does depends on the Compiler NOT on code::blocks.

I never use the static option; so, no idea where is the correct location or what it really does.
Memory says it changed whether the gcc c lib is static or a DLL.

Tim S.
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

dcbdbis

  • Guest
Re: C::B 13.12 -static not working
« Reply #14 on: August 06, 2014, 04:09:01 am »
Once I get to the bottom of this...I will be posting the solve back here for others...

It may be an idea to ship C::B with a version of wxWidgets pre-compiled with the same compiler and widget version that C::B itself is built on...It would save folks some time and headache.

But that is a wish-list....


FYI.


Dave