I'm trying to set up my Netbeans IDE so that it is capable of compiling wxWidgets projects.
There is very similar question:
Setup wxWidget in Netbeans 6.1 C++ On MS Windows?
but the answer is not working for me. And the mentioned versions are a bit outdated.
I use the mingw package for compilation.
There is no problem compiling a small hello World App from the console using this command in mysys:
$ g++ hello.cpp `wx-config --libs` `wx-config --cxxflags` -o hello.exe
So here's what I tried in Netbeans:
Project properties:
C++ Compiler -> Additional Options: wx-config cxxflags (surrounded by backticks)
C++ Compiler -> Include directories: installation_Path/include
Linker -> Additional Options: wx-config --libs (surrounded by backticks)
The command lines Netbeans creates when I try to compile seem to be correct to me
g++.exe `wx-config --cxxflags` -c -g -I/D/lib/wxWidgets/include -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
This compiles without errors
g++.exe `wx-config --cxxflags` `wx-config --libs` -o dist/Debug/MinGW-Windows/wxwidgetstest build/Debug/MinGW-Windows/main.o -L/D/lib/wxWidgets/lib/gcc_lib
But during the linking process I get loads of errors...
Questions:
Does anybody have a working configuration for compiling wxWidgets Projects from within Netbeans and can help me out
Or does anybody see an error in the command lines could be the reason for the linking problems ?
Thank you very much!
I finally found the solution, and wrote a guide for anyone who might encounter the same problem in the future.
wxWidgets wiki: Compiling using Netbeans
Related
So I'm trying to run an example SFML program on my Windows laptop. If relevant, the source code is on this page.
So first I make the .o file using this command -
g++ -c a.cpp -ISFML/SFML/include
Where a.cpp is the main file, and my SFML package is located in SFML/SFML.
Then I compile using this command -
g++ a.o -o a -LSFML/SFML/lib -lsfml-graphics -lsfml-window -lsfml-system
When I first ran the program I got the errors about not being able to find certain dlls, sfml-graphics-2 etc. So I found them and put them next to the exe. But now when I run, I get this weird error:
The procedure entry point
_ZNSt7__cxx1112basic_stringSt11char_traitsIcESalcEE7reserveEj could not be located in the dynamic link library.
What is going on here?
As the SFML download page states, You could be using the wrong version of the compiler, other library versions of SFML that you have not removed from your working directory that could mismatch between code and linker. Worst case, if your compiler is not listed there, you have to compile SFML yourself:
Get CMake. Get the source code for 2.4.2 by going to the bottom of the SFML download page. Follow this guide on SFML's GitHub repo. Alternatively, you could use the guide on SFML's page but it is for an older version. It might answer some questions that the first guide misses.
Ones CMake have generated the makefiles, you're on your way to build SFML.
Good luck!
I've had this problem for so long so I just wanted to help someone out who had the same problem. I have a windows 10 FYI and MinGW-w64 8.1.0 (if it doesnt work try a 32 bit mingw instead)
for a debug mode (debug is when your still working on the game and would like command prompt to open whenever you run it)
(make sure your in the right directory first by doing "cd")
g++ -c (file_name).cpp -o (file_name).o -I(path_to)SFML-64-bit/include -g -m64 -Wall &&
g++ (file_name).o -o (game_name).exe -L(path_to)SFML-64-bit/lib -lsfml-graphics -lsfml-window -lsfml-system
The code above when placed in command will compile everything for you if its all in the same directory so make sure you keep an eye out for that
and now for release mode (if you dont want command prompt to show up)
g++ -c (file_name).cpp -o (file_name).o -I(path_to)SFML-64-bit/include -O3 -m64 &&
g++ (file_name).o -o (game_name).exe -L(path_to)SFML-64-bit/lib -lsfml-graphics lsfml-window -lsfml-system -mwindows
Noticed all I added was the -mwindows and the -O3 aswell as removing -g and -Wall which are not necessary since we wont be using command prompt
Make sure to go to SFML/bin and take all the .dlls and put it into the same directory has your .exe sorry xd
Hope this helped.
I am refactoring an old Borland C/C++98 program. I would like to program it under linux platform but to beginning, as I have severals additionnals boards, I clean the program, remove all GUI OWL and make tests under win7 and mingw64 to use modern gcc/g++.
I actually try to link a sample code that use C320 turbo Moxa multiport serial board.
As mentionned in
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use
it should link .lib and .dll.
So I tried to link my sample with Moxa PComm.lib for sio_open, sio_read, sio_write… functions as
g++ -m32 -Wall -std=c++14 src/main.cpp src/rs232_c320t.cpp … -L./lib -lPComm
and it returns
./lib/PComm.lib: file not recognized: File format not recognized
Are there any options to allow link windows .lib with gcc/g++ under mingw64?
Thanks
This related "Linking *.lib files with MinGW" question doesn't mention "File format not recognize" error. See also my comments below.
bcag2
I downloaded last PCommLite for win7 x64.
Copy C:\Program Files\Moxa\PCommLite 1.6\Include\PCOMM.H in my include project folder (lib in my case), and do the same for files PCOMM.dll and PCOMM.lib in C:\Program Files\Moxa\PCommLite 1.6\Lib\x64.
Then I compile with:
g++ -c -std=c++14 -D_hypot=hypot -DWIN32 src/*.cpp -I./lib/
Where -I./lib give access to PCOMM.H and link with:
g++ -shared *.o lib/PCOMM.LIB /c/Windows/System32/msvcr120.dll /c/ProgramData/Anaconda3/python36.dll -o _project.pyd
Of course you can do all in one time and create an .exe:
g++ -o project.exe -Wall -std=c++14 -DWIN32 src/*.cpp -Ilib/ lib/PCOMM.LIB -L./lib/
NO -ansi required as suggested by Moxa support!
I have installed CPLEX 12.6.3 (CPLEX_Studio_Community1263) and I want to integrate CPLEX in my Eclipse C++ project (on Linux). But I don't know which steps I have to follow to include CPLEX in my project.
Even by following exactly the steps shown at this link, it still not working for me (I can't import cpelx.jar in my project). The path of my cplex.jar is
/opt/ibm/ILOG/CPLEX_Studio_Community1263/cplex/lib/cpelx.jar
When I right-click on my project and go to
Properties --> Settings --> GCC C++ Linker --> Libraries
to add the cplex.jar in my project, it is impossible to add the .jar because I can't select it (it is deselected and impossible to select it).
Can some one explain me how I can include CPLEX in my project?
The link you reference is for setting up a Java program. This will not help you.
Instead, you should try running one of the C++ examples shipped with CPLEX. Try the following (assuming your path is correct from above):
$ cd /opt/ibm/ILOG/CPLEX_Studio_Community1263/cplex/examples/x86-64_linux/static_pic
$ make ilolpex1 2>&1 | tee output.txt
This will save the output in output.txt so that you can look at it later. It should give you an idea of what the required command line arguments are.
For example, on my system (x86-64_linux), I see this in the output:
$ make ilolpex1
g++ -O0 -c -m64 -O -fPIC -fno-strict-aliasing -fexceptions -DNDEBUG -DIL_STD -I../../../include -I../../../../concert/include ../../../examples/src/cpp/ilolpex1.cpp -o ilolpex1.o
g++ -O0 -m64 -O -fPIC -fno-strict-aliasing -fexceptions -DNDEBUG -DIL_STD -I../../../include -I../../../../concert/include -L../../../lib/x86-64_linux/static_pic -L../../../../concert/lib/x86-64_linux/static_pic -o ilolpex1 ilolpex1.o -lconcert -lilocplex -lcplex -lm -lpthread
This tells you everything you need to know to compile and link your program. You'll just need to figure out where to enter this information in Eclipse.
I'm doing some experimenting with magick++ and when I compile my snippets I just use g++ and type g++ test.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs` -o prog but I have recently fallen in love Code:Blocks and I'm wondering how I can tell it to compile like above? I haven't been able to figure it out on my own.
Open from menu →Project →Build Options
Navigate to →Compiler settings →OtherOptions and enter:
$\(Magick++-config --cppflags --cxxflags\)
Navigate to →Linker settings and enter to →Other linker options:
$\(Magick++-config --ldflags --libs\)
Escaping \( and \) are necessary.
Remember to select the project on left, not a build target.
So I have this Wx application written in C++ that I've tested under Linux Mint, Ubuntu, and even Mac but under Arch Linux it doesn't seem to link correctly. I've installed the wxgtk library required and the compilation works fine but when it gets to the linking stage I get a lot of output saying that none of the Wx methods could be found. wx-config --libs output looks correct to me so I'm not sure what's causing the problem. I will post my Makefile if necessary but it seems this issue is only specific to Arch Linux so far.
Just in case anyone is bashing their head over this I changed the linker line from
g++ `wx-config --libs` -o $(OBJS)
to
g++ -o $(OBJS) `wx-config --libs`
The reason for this is detailed in rodrigo's comment below.