Making WxWidgets work in C++ - c++

I installed precompiled WxWidget libraries and tried to run the default program in CodeBlocks but it gives the following error:
mingw32-g++.exe: error: bin\Release\new2.exe: No such file or directory
Paths for WxWidget Libraries and MinGW are already specified.
My question is; How to make CodeBlocks generate a .exe file for WxWidgets project?
I have already tried all solutions listed in this question: "No such file or directory" error in CodeBlocks
Complete Build Log:
-------------- Build: Release in new2 (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -Wno-unused-
local-typedefs -Wall -O2 -ID:\WxWidgets\wxWidgets2.8\include -I\msw -c
C:\Users\ShifaShah\Documents\new2\new2App.cpp -o obj\Release\new2App.o
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -Wno-unused-
local-typedefs -Wall -O2 -ID:\WxWidgets\wxWidgets2.8\include -I\msw -c
C:\Users\ShifaShah\Documents\new2\new2Main.cpp -o obj\Release\new2Main.o
windres.exe -ID:\WxWidgets\wxWidgets2.8\include -I\msw -J rc -O coff -i
C:\Users\SHIFAS~1\DOCUME~1\new2\resource.rc -o obj\Release\resource.res
mingw32-g++.exe -L -o bin\Release\new2.exe obj\Release\new2App.o
obj\Release\new2Main.o obj\Release\resource.res -s -mthreads -lwxmsw_core -lwxbase -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -
ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
mingw32-g++.exe: error: bin\Release\new2.exe: No such file or directory
Process terminated with status 1 (0 minute(s), 3 second(s))
1 error(s), 0 warning(s) (0 minute(s), 3 second(s))

-L -o bin\Release\new2.exe
Here's the problem. The -L flag requires an argument, but the usual argument (a directory to search for libraries) is not provided. So the next flag, -o, is interpreted as an argument to -L, and bin\Release\new2.exe is interpreted as a name of an input file, which of course doesn't exist yet.
Check your compiler flags and make sure there's no stray -L anywhere, and no "additional libraries directory" is specified as a white space string or similar.

Related

wxwidget 3.1.2 codeblocks 17.04 error at linking step

OS : windows 10 64 bit
IDE : codeblocks 17.12
Compiler : gcc 7.3
with
wxWidget 3.1.2
i build wxWidget 3.1.2 according to the official guide without changing any defaults
make -f makefile.gcc (make v4.2)
i am using codeblocks wxwidget start script 3.1.X
i have choosen correct option according to the wxWidget build
(Monolithic unicode and debug)
The codeblock generated sample problem is not linking properly
( gives build fail with 0 error 0 warning )
-------------- Clean: Debug in sac (compiler: GNU GCC Compiler)---------------
Cleaned "sac - Debug"
-------------- Build: Debug in sac (compiler: GNU GCC Compiler)---------------
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c C:\Users\MC\Desktop\wxw\sac\wx_pch.h -o wx_pch.h.gch\Debug_wx_pch_h_gch
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c C:\Users\MC\Desktop\wxw\sac\GUIFrame.cpp -o obj\Debug\GUIFrame.o
windres.exe -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -J rc -O coff -i C:\Users\MC\Desktop\wxw\sac\resource.rc -o obj\Debug\resource.res
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c C:\Users\MC\Desktop\wxw\sac\sacApp.cpp -o obj\Debug\sacApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -Winvalid-pch -include wx_pch.h -DWX_PRECOMP -Wall -g -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c C:\Users\MC\Desktop\wxw\sac\sacMain.cpp -o obj\Debug\sacMain.o
g++.exe -LC:\wxWidgets-3.1.2\lib\gcc_dll -o bin\Debug\sac.exe obj\Debug\GUIFrame.o obj\Debug\sacApp.o obj\Debug\sacMain.o obj\Debug\resource.res -mthreads -lwxmsw31u -mwindows
Process terminated with status 1 (0 minute(s), 11 second(s))
Process terminated with status 1 (0 minute(s), 11 second(s))
Process terminated with status 1 (0 minute(s), 12 second(s))
0 error(s), 0 warning(s) (0 minute(s), 12 second(s))
any help ?
This post assumes you have compiled wxWidgets 3.1.3 and are successful in compiling the executable samples via make and makefile.gcc that is included and are using gcc.
It also assumes you have already applied your environment vars in windows, applied your compiler flags wx-config --cxxflags and linker flag wx-config --libs.
It seems everyone else has dugout the makefile library order and has fixed it inside of codeblocks. I wanted to build small all in one apps so I decided on a MONOLITHIC with SHARED=0 UNICODE build.
It seems the easiest fix is thus.
CodeBlocks arranges the linker library order in a different order than the makefile does and jams up the linker, in my case varying from "theme" something or other to scrollbar issues.
So the quickest work around I've found is to delete all the entries in the codeblocks build options lists and enter only into the "Other Linker Options" for Debug and Release and this does work.
So from the console listing the makefile shows copy those linker settings in the order that makefile settings list. So until someone makes a header fixup entry for something higher than 2.8.8 there is this cumbersome workaround.
In my case the working order is as follows:
-mwindows
-lwxmsw31ud
-lwxmsw31ud_gl
-lwxscintillad
-lwxtiffd
-lwxjpegd
-lwxpngd
-lwxzlibd
-lwxregexud
-lwxexpatd
-lkernel32
-luser32
-lgdi32
-lcomdlg32
-lwinspool
-lwinmm
-lshell32
-lshlwapi
-lcomctl32
-lole32
-loleaut32
-luuid
-lrpcrt4
-ladvapi32
-lversion
-lwsock32
-lwininet
-loleacc
-luxtheme
In Release it is the same less the "d" which designates the debug file i.e.:
-lwxmsw31u_gl instead of -lwxmsw31ud_gl,
-lwxtiff in place of -lwxtiffd etc...

Error while compiling JUMPCoin Wallet on Raspberry Pi (leveldb/libmemenv.a: error adding symbols:)

I am trying to compile a wallet for my JUMP coins (https://github.com/Jumperbillijumper/jumpcoin).
I cloned the repo,
cd to src/
and ran $ make -f makefile.unix
and now I am getting this error:
/home/pi/jumpcoin/jumpcoin/src/leveldb/libmemenv.a: error addingsymbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
makefile.unix:206: recipe for target 'jumpcoind' failed
make: *** [jumpcoind] Error 1
Log:
pi#Raspberry_Pi:~/jumpcoin/jumpcoin/src $ make -f makefile.unix
/bin/sh ../share/genbuild.sh obj/build.h
g++ -c -O2 -pthread -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/pi/jumpcoin/jumpcoin/src -I/home/pi/jumpcoin/jumpcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/pi/jumpcoin/jumpcoin/src/leveldb/include -I/home/pi/jumpcoin/jumpcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2 -MMD -MF obj/txdb-leveldb.d -o obj/txdb-leveldb.o txdb-leveldb.cpp
g++ -O2 -pthread -Wall -Wextra -Wno-ignored-qualifiers -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/home/pi/jumpcoin/jumpcoin/src -I/home/pi/jumpcoin/jumpcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/home/pi/jumpcoin/jumpcoin/src/leveldb/include -I/home/pi/jumpcoin/jumpcoin/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2 -o jumpcoind obj/groestl.o obj/blake.o obj/skein.o obj/keccak.o obj/jh.o obj/alert.o obj/version.o obj/checkpoints.o obj/netbase.o obj/addrman.o obj/crypter.o obj/key.o obj/db.o obj/init.o obj/irc.o obj/keystore.o obj/miner.o obj/main.o obj/net.o obj/protocol.o obj/jumpcoinrpc.o obj/rpcdump.o obj/rpcnet.o obj/rpcmining.o obj/rpcwallet.o obj/rpcblockchain.o obj/rpcrawtransaction.o obj/script.o obj/sync.o obj/util.o obj/wallet.o obj/walletdb.o obj/noui.o obj/kernel.o obj/pbkdf2.o obj/scrypt.o obj/scrypt-arm.o obj/scrypt-x86.o obj/scrypt-x86_64.o obj/zerocoin/Accumulator.o obj/zerocoin/AccumulatorProofOfKnowledge.o obj/zerocoin/Coin.o obj/zerocoin/CoinSpend.o obj/zerocoin/Commitment.o obj/zerocoin/ParamGeneration.o obj/zerocoin/Params.o obj/zerocoin/SerialNumberSignatureOfKnowledge.o obj/zerocoin/SpendMetaData.o obj/zerocoin/ZeroTest.o obj/txdb-leveldb.o -Wl,-z,relro -Wl,-z,now -Wl,-Bdynamic -l boost_system -l boost_filesystem -l boost_program_options -l boost_thread -l db_cxx -l ssl -l crypto -l miniupnpc -Wl,-Bdynamic -l z -l dl -l pthread /home/pi/jumpcoin/jumpcoin/src/leveldb/libleveldb.a /home/pi/jumpcoin/jumpcoin/src/leveldb/libmemenv.a
/home/pi/jumpcoin/jumpcoin/src/leveldb/libmemenv.a: error adding symbols: Archive has no index; run ranlib to add one
collect2: error: ld returned 1 exit status
makefile.unix:206: recipe for target 'jumpcoind' failed
make: *** [jumpcoind] Error 1
ok the problem was in the src/leveldb directory (obviously)
I took the src/leveldb directory from this repo (https://github.com/sagacrypto/SagaCoin) and replaced the current one. Then everything works fine. (at least for me :P)
yeah I know it is not best practice but this one was driving me nuts :D

wxWidgets 3.1.0 project error on windows 10

i am a newbie here and i need help in compiling my wxwidgets project to work with codeblocks.
i downloaded wxwidgets windows intaller 'wxMSW-3.1.0-Setup.exe' from http://www.wxwidgets.org/downloads/
i run the program to install, then i read about making environmental variable at system properties>>advanced system settings>>environment variables. thus i made it by setting variable name as "path" and variable value as "C:\Program Files (x86)\CodeBlocks\MinGW\bin".
also read about making builds for wxwidget in cmd prompt, so launch cmd and input such procedures below (some which took a long time).
mingw32-make -v
cd C:\wxWidgets-3.1.0\build\msw
mingw32-make -f makefile.gcc clean
mingw32-make -f makefile.gcc BUILD=debug SHARED=0 MONOLITHIC=1 UNICODE=1
mingw32-make -f makefile.gcc BUILD=release SHARED=0 MONOLITHIC=1 UNICODE=1
after all that i went on to make a wxwidgets project.
i got two errors when making wxwidgets project "a matching debug configuration cannot be found in the wxwidgets directory you specified" and "a matching release configuration cannot be found in the wxwidgets directory you specified"
but then i skip and went on to project, after build and run i got these errors below.
Build log for debug:
-------------- Build: Debug in testwx (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -LC:\wxWidgets-3.1.0\lib\gcc_lib -o bin\Debug\testwx.exe obj\Debug\testwxApp.o obj\Debug\testwxMain.o obj\Debug\resource.res -mthreads -lwxmsw30u -lwxpng -lwxjpeg -lwxtiff -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lwxmsw30u
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 5 second(s))
2 error(s), 0 warning(s) (0 minute(s), 5 second(s))
Build log for release:
-------------- Build: Release in testwx (compiler: GNU GCC Compiler)---------------
windres.exe -IC:\wxWidgets-3.1.0\include -IC:\wxWidgets-3.1.0\lib\gcc_lib\mswu -J rc -O coff -i C:\Users\AJIKAH~1\DOCUME~1\Programs\WXWIDG~1\testwx\resource.rc -o obj\Release\resource.res
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -O2 -std=c++11 -IC:\wxWidgets-3.1.0\include -IC:\wxWidgets-3.1.0\lib\gcc_lib\mswu -c "C:\Users\A JIKAH\Documents\Programs\wxWidgets\testwx\testwxApp.cpp" -o obj\Release\testwxApp.o
mingw32-g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -O2 -std=c++11 -IC:\wxWidgets-3.1.0\include -IC:\wxWidgets-3.1.0\lib\gcc_lib\mswu -c "C:\Users\A JIKAH\Documents\Programs\wxWidgets\testwx\testwxMain.cpp" -o obj\Release\testwxMain.o
mingw32-g++.exe -LC:\wxWidgets-3.1.0\lib\gcc_lib -o bin\Release\testwx.exe obj\Release\testwxApp.o obj\Release\testwxMain.o obj\Release\resource.res -s -mthreads -lwxmsw30u -lwxpng -lwxjpeg -lwxtiff -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: cannot find -lwxmsw30u
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 33 second(s))
2 error(s), 0 warning(s) (0 minute(s), 33 second(s))
now i update code::blocks 16.01 to code::blocks 17.01.
can someone pls help me solve this problem?
You said you downloaded "wxMSW-3.1.0-Setup.exe". But this part "...cannot find -lwxmsw30u..." means you're trying to link with libraries from wxWidgets 3.0.
To make sure your project is trying to link with the correct version of wxWidgets, on the second page of the codeblocks wizard (the one that says "Please select the wxWidgets version you want to use"), be sure to select the "wxWidgets 3.1.x" option.
Another common cause of the "matching configuration cannot be found" problem is not selecting the right options on the 8th page of the wizard (the one that says "Please select various configuration options"). Since you said you build the library with the options " SHARED=0 MONOLITHIC=1 UNICODE=1", be sure to check "wxWidgets is built as a monolithic library" and "Enable unicode" and be sure "Use wxWidgets DLL" is unchecked.
#MrSudden,
Is there any reason why you built the library as MONOLITHIC?
This configuration, also supported, is not recommended and can cause problems in the long run.
It is also does not have a big testing from the core wx team, and so have a big chances of breakage.
There is no gain of building "monolithic" library vs. "multilib" one.
Thank you.

Linker fail: member in archive is not an object

I'm trying to build Open CASCADE (6.7.1) library with 64bit mingw on Windows 7 (I am using x86_64-4.9.1-release-posix-seh-rt_v3-rev1 from mingw-w64 project).
When it comes to linking, it fails with an error and I have no idea what could be wrong. The linker command generated by cmake is:
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E remove -f CMakeFiles\TKernel.dir/objects.a
C:\msys64\mingw64\bin\ar.exe cr CMakeFiles\TKernel.dir/objects.a #CMakeFiles\TKernel.dir\objects1.rsp
C:\msys64\mingw64\bin\g++.exe -shared -o ..\out\bin\libTKernel.dll -Wl,--out-implib,..\out\lib\libTKernel.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles\TKernel.dir/objects.a -Wl,--no-whole-archive -LC:\msys64\home\user\tcl8.5.16\build -LC:\msys64\home\user\freetype-2.5.3 -ladvapi32 -lgdi32 -luser32 -lkernel32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
And the produced error:
Linking CXX shared library ..\out\bin\libTKernel.dll
CMakeFiles\TKernel.dir/objects.a: member CMakeFiles\TKernel.dir/objects.a(FSD_BinaryFile.cxx.obj) in archive is not an object
collect2.exe: error: ld returned 1 exit status
TKernel\CMakeFiles\TKernel.dir\build.make:11422: recipe for target 'out/bin/libTKernel.dll' failed
This is how the files are compiled:
Building CXX object TKernel/CMakeFiles/TKernel.dir/__/__/src/FSD/FSD_BinaryFile.cxx.obj
cd /d TKernel && C:\msys64\mingw64\bin\g++.exe -DCSFDB -DTKernel_EXPORTS -DWNT -D_OCC64 -D_SCL_SECURE_NO_WARNINGS -MP -Wall -O3 -DNDEBUG -DNo_Exception #CMakeFiles/TKernel.dir/includes_CXX.rsp -MM -D__FSD_DLL -D__MMgt_DLL -D__OSD_DLL -D__Plugin_DLL -D__Quantity_DLL -D__Resource_DLL -D__SortTools_DLL -D__Standard_DLL -D__StdFail_DLL -D__Storage_DLL -D__TColStd_DLL -D__TCollection_DLL -D__TShort_DLL -D__Units_DLL -D__UnitsAPI_DLL -D__IncludeLibrary_DLL -D__Dico_DLL -D__NCollection_DLL -D__Message_DLL -o CMakeFiles\TKernel.dir\__\__\src\FSD\FSD_BinaryFile.cxx.obj -c ..\..\src\FSD\FSD_BinaryFile.cxx
If I check the objects.a file with nm, the contents are .obj, but "File format not recognized" doesn't look good... but don't know what exactly does that mean...
$ nm objects.a
C:\msys64\mingw64\x86_64-w64-mingw32\bin\nm.exe: FSD_BinaryFile.cxx.obj: File format not recognized
C:\msys64\mingw64\x86_64-w64-mingw32\bin\nm.exe: FSD_CmpFile.cxx.obj: File format not recognized
...
Output from file command:
$ file objects.a
objects.a: current ar archive
$ file __/__/src/FSD/FSD_BinaryFile.cxx.obj
__/__/src/FSD/FSD_BinaryFile.cxx.obj: ASCII text, with CRLF line terminators
I also tried to remove the --whole-archive option from the linker command, but that leads to another error:
Linking CXX shared library ..\out\bin\libTKernel.dll
CMakeFiles\TKernel.dir/objects.a: error adding symbols: Archive has no index; run ranlib to add one
collect2.exe: error: ld returned 1 exit status
If I run ranlib on the file, it doesn't help.
Any ideas are appreciated.
edit: Ok, so I guess that the problem is caused by -MM flag, that was used for the build. So it didn't really compile the files, if I understand it correctly.
However I found OCE project, which is some sort of community edition of OCC and it is quite mingw-ready, so I'm gonna use that version and see how it goes...

Code::Blocks linking not working, on prompt it does

I'm having quite a bit of trouble linking a test project of FLTK I'm doing on Code::Blocks, Windows 7.
After spending quite a lot of time understanding how to put the libraries in the correct order, I managed to get the project nearly done. However there's still a linking problem:
mingw32-g++.exe -Wall -fexceptions -IC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0 -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -c C:\Users\Svalorzen\Documents\Projects\test\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\test.exe obj\Debug\main.o -LC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib -mwindows -lfltk -lole32 -luuid -lcomctl32
C:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib/libfltk.a(Fl_Native_File_Chooser.o):Fl_Native_File_Chooser.cxx:(.text+0x1556): undefined reference to `__chkstk_ms'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings
However, using the same exact script that Code::Blocks shows, executed on command prompt ( or even msys for what matters ), correctly compiles and links everything. The resulting exe also works.
C:\Users\Svalorzen\Documents\Projects\test>mingw32-g++ -Wall -fexceptions -IC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0 -mwindows -DWIN32 -DUSE_OPENGL32 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -c C:\Users\Svalorzen\Documents\Projects\test\main.cpp -o obj\Debug\main.o
C:\Users\Svalorzen\Documents\Projects\test>mingw32-g++ -o bin\Debug\test.exe obj\Debug\main.o -LC:\Users\Svalorzen\Documents\Projects\fltk-1.3.0\lib -mwindows -lfltk -lole32 -luuid -lcomctl32
C:\Users\Svalorzen\Documents\Projects\test>dir bin\Debug\test.exe
Volume in drive C has no label.
Volume Serial Number is 00E8-6659
Directory of C:\Users\Svalorzen\Documents\Projects\test\bin\Debug
10/05/2012 19:01 661.087 test.exe
1 File(s) 661.087 bytes
0 Dir(s) 66.016.849.920 bytes free
The paths in the instruction are all absolute, so I don't really understand why this is.
What am I doing wrong? What I should check?
EDIT: It turned out that I had a MinGW installation I didn't remember about and Code::Blocks was using that one. I changed it and now everything is fixed.
If your MinGW is up-to-date, then try adding -no-vcproj and -no-dsp and then run mingw32-make confclean.
It turned out that I had a MinGW installation I didn't remember about and Code::Blocks was using that one.
I setup Code::Blocks with the same compiler that created the library and now everything is fine.