I can't even get the wxWidgets samples to compile using a - c++

So I have been trying to get even just the damn samples for wxWidgets to compile with Mingw and I did like so mingw32-make -f makefile.gcc and I get the following error.
I do not have MSYS installed, and I have the latest version of Mingw
g++ -c -o gcc_mswud\minimal_minimal.o -g -O0 -mthreads -DHAVE_W32API_H -D__WXMS
W__ -D_UNICODE -I.\..\..\lib\gcc_lib\mswud -I.\..\..\include -W -Wall -I
. -I.\..\..\samples -DNOPCH -Wno-ctor-dtor-privacy -MTgcc_mswud\minimal_min
imal.o -MFgcc_mswud\minimal_minimal.o.d -MD -MP minimal.cpp
In file included from .\..\..\include/wx/defs.h:26:0,
from .\..\..\include/wx/wxprec.h:13,
from minimal.cpp:21:
.\..\..\include/wx/platform.h:256:22: fatal error: wx/setup.h: No such file or d
irectory
compilation terminated.
mingw32-make: *** [gcc_mswud\minimal_minimal.o] Error 1'
Any advice would be greatly appreciated
Also how exactly should I be compiling my own projects involving wxWidgets, what do I need to link against wxWidgets in mingw?

wx/setup.h is a file that is created during the compilation process; this file will be different for each different build type (Unicode, ANSI, Debug or Release, etc.). Most likely you compiled wxWidgets for one build type and are trying to compile the samples for a different build type.
As for the include / linker paths I have found the settings below to the bare minimum required to use wxWidgets in your own projects on Windows:
Include Paths
$(WXWIN)\include
$(WXWIN)\lib\vc_lib\mswud (u = Unicode and d=debug, this changes depending on what build type you want)
Pre-processor Definitions
WIN32
_DEBUG (only if you want to build with debugging info)
_WINDOWS
Character Set
"Use Unicode Character Set" (very important for Unicode builds; otherwise you will get compiler errors)
Additional Library Directories
$(WXWIN)\lib\vc_lib
Additional Dependencies
winmm.lib
comctl32.lib
rpcrt4.lib
wsock32.lib
odbc32.lib
wxmsw28ud_core.lib
wxbase28ud.lib
wxexpatd.lib
wxjpegd.lib
wxpngd.lib
wxregexud.lib
wxtiffd.lib
wxzlibd.lib
wxmsw28ud_adv.lib
wxmsw28ud_aui.lib
wxmsw28ud_html.lib
wxWidgets libraries are post-fixed with "u" for Unicode and "d" for debug, you need to choose the libraries that match the build type you want. $(WXWIN) is the directory where you built wxWidgets (wxPack will create this environment variable for you to use).

Related

Add C++ Library to eclipse C++ Project

I am attempting to add an existing library to Eclipse. I use a cross compiler for C++ with the Eclipse IDE, installed on a virtual linux debian machine.
The mmapGpio lib is found here.
/mmapGpioBasicRev1.tar.gz has a cpp and an h file with a small demo program.
I have compiled this code without a problem. A .o file is generated. I've archived the file successfully with ar -q libmmapGpio.a mmapgpio.o
I've placed my libmmapGpio.a in ~/.../UserLib directory
I've placed my mmapGpio.h in ~/.../UserInclude
At this point all is OK.
I open a new project that uses the mmapGpio library:
#include "mmapGpio.h"
#include "stdio.h"
int main(void){
mmapGpio rpiGpio; // instantiate an instance of the mmapGpio class
rpiGpio.setPinDir(17,mmapGpio::OUTPUT); // set GPIO17 to output
while(1) {// toggle pin as fast as possible
rpiGpio.writePinHigh(17);
rpiGpio.writePinLow(17);
}
return 0;
}
So cross-compilation is done, but linker say cannot find -llibmapGpio!
I have made declaration in the properties project; C/C++ General
includes path : /home/octopuss/rpi/UserInclude (the mmapGpio.h file)
Library path : /home/octopuss/rpi/UserLib (the libmmapGpio.a file)
Libraries : libmmapGpio
Why do I receive this message?
for detail -> console view
03:16:30 **** Build of configuration Debug for project Gpio1 ****
make all
Building file: ../Gpio1.cpp
Invoking: Cross G++ Compiler
arm-linux-gnueabihf-g++ -I/home/octopuss/rpi/UserInclude -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"Gpio1.d" -MT"Gpio1.d" -o "Gpio1.o" "../Gpio1.cpp"
Finished building: ../Gpio1.cpp
Building target: Gpio1
Invoking: Cross G++ Linker
arm-linux-gnueabihf-g++ -L/home/octopuss/rpi/UserLib -o "Gpio1" ./Gpio1.o -lmmapGpio
/home/octopuss/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: skipping incompatible /home/octopuss/rpi/UserLib/libmmapGpio.so when searching for -lmmapGpio
/home/octopuss/rpi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lmmapGpio
collect2: error: ld returned 1 exit status
make: *** [Gpio1] Erreur 1
error :
skipping incompatible /home/.../UserLib/libmmapGpio.so when searching for -lmmapGpio
ld: cannot find -lmmapGpio
"why this message ?"
It's because with your settings, the linker actually looks up for a library file named liblibmmapGpio.a.
"... so crosscompilation is done but linker say "cannot find -llibmapGpio" !
...
- Libraries : libmmapGpio"
You just need to specify the library without the lib prefix in the linker library settings:
mmapGpio
The Eclipse CDT Builder passes this as a -l option to the linker, which automatically extends to search for libmmapGpio.a at the specified additional pathes.
See also this Q&A for more illustrated samples and links:
Problems importing libraries to my c++ project, how to fix this?
I found the problem ... my .so lib wasn't ARM cross compiled so there is a X86 library not compatible whith my ARM Programm.
I solve this to set erm-linuxgnuabihf- prefix and his path to cross setting parameter.
Thanks to TTAVAR PEI and Scott Stensland
enjoy

C++ make link step : Undefined symbols for architecture x86_64

I am trying to link a compiled research experiment project, built in C/C++.
The project is dependant on HyperNEAT and robot simulation software WeBots.
I have cloned and built the HyperNEAT project successfully (in that project there are other dependancies such as Boost, TinyXML, JGTL (custom library) and other unrelated subprojects).
I have made a makefile including all neccesary header search paths and library paths, and compiling the two main .cpp files:
/ModHyperNEAT/mod_ctrler7.cpp
/ModSupervisor/mod_supervisor.cpp
works, giving me 2 .o files.
However, in the make link step, when I want to create (separate) executables of both files, I am getting the 'undefined symbols for architecture x86_64' error (see pastebin here: http://pastebin.com/kiwwCcUf). It seems that C++ standard datatypes and functions such as
std::string::end() const cannot be found.
I have googled and searched SO for answers regarding this, and it seems that either libraries are missing or binary incompatible if i understand correctly, but the libraries are there and both projects have been compiled with the -lstdc++ flag.
This is the make link step (and the used macro's from the makefile) :
CC = gcc
CFLAGS = -v -g -lstdc++ -Wall -Wno-error -ferror-limit=100 -fmessage-length=0
DEFINES = -DHCUBE_NOGUI -DTIXML_USE_STL
FLAGS = $(CFLAGS) $(DEFINES)
LIB_TINYXML = -L/Users/michahell/Documents/projects_c++/HyperNEAT/tinyxmldll/out
LIB_HYPERNEAT = -L/Users/michahell/Documents/projects_c++/HyperNEAT/NE/HyperNEAT/out
LIB_BOOST = -L/usr/local/Cellar/boost/1.57.0/lib
LIB_WEBOTS = -I/Applications/Webots/lib
LIBS = $(LIB_TINYXML) $(LIB_HYPERNEAT) $(LIB_BOOST) $(LIB_WEBOTS)
LIBFLAGS = -ltinyxmlpluslib -lboost_filesystem-mt -lboost_random-mt -lboost_system-mt -lNEATLib_d -lHypercube_NEAT_Base_d
WEBOTS_DYLIB = -dylib_file /Applications/Webots/lib/libController.dylib:/Applications/Webots/lib/libController.dylib
$(CC) $(FLAGS) $(LIBS) ./mod_ctrler7.o $(WEBOTS_DYLIB) $(LIBFLAGS)
I found out that to link to .dylib's I had to use a specific flag and specify the full path, hence the $(WEBOTS_DYLIB) macro.
I am using the -lstdc++ flag because in the HyperNEAT project that flag was also used for building that library. If i exclude this flag, i get a lot of errors during compilation (libc++ and libstdc++ incompatibility as I now understand). All of the library paths check out, and .a and/or .dylib files are present.
My knowledge of C/C++ and GCC tooling is very limited, as I have never had to use it before.
I think it might have to do with the fact that the HyperNEAT project contains a Boost 1.57.0 distribution which is used for their build, and that i have a separate (using homebrew) Boost version installed on my system, which is the same version:
$ brew info boost
boost: stable 1.57.0 (bottled), HEAD
http://www.boost.org
/usr/local/Cellar/boost/1.57.0 (10572 files, 439M) *
What could be the cause of this error failing my link step? Anyone should be able to reproduce my linker errors if both HyperNEAT and my project are cloned and put their root dirs in the same location. WeBots should be downloaded but only for the header includes and libraries. And of course my makefile paths should be modified.
If anyone can give me tips on how to solve this problem, i would GREATLY appreciate it!
It turns out that, for some reason, I had to include the lstdc++ flag to the library link flags and not as a compiler flag, AND the stdlib=libstdc++ as compiler flag.

Compile XCode 5 project with custom flags

I have a cpp file which I am able to compile from command line using:
clang++ main.cpp -O2 -larmadillo
or by using g++ compiler via
g++ main.cpp -O2 -larmadillo
My question is how can I compile main.cpp in Xcode 5.1.1?
Here is what I tried:
1) Project -> Build Settings -> Other C++ flags -> added '-O2 -larmadillo' there
2) Target -> Build Settings -> Other C++ flags -> added '-O2 -larmadillo' there
Neither helped.
I am new to this linking/compiling magic so I don't know where to go from here.
clang++ and g++ can act as both compilers and as compiler drivers. When you run them from the command line as a compiler driver they internally handle running all the steps for getting an executable, including compiling, assembling, and linking.
But when Xcode is doing the build it instead expects to run clang as a compiler and to handle linking separately. So passing a linker flag in 'Other C++ flags' is basically like doing:
// compile step (no linking)
clang++ main.cpp -O2 -larmadillo -c
// linking step (error, missing library)
clang++ main.o
So what you need to do is change the build settings so that Xcode knows that it needs to link in that library when it gets to the linking step. A quick and dirty way would be to add the linker flag to 'other linker flags' (and to set the library search paths appropriately), but it would be better to edit your target's 'Build Phases" and update the "Link Binary with Libraries" with the appropriate library. You may also need to change the SDK in the target's build settings to 'Current Mac OS', so that Xcode will use whatever libraries you've installed rather than strictly limiting it to what's available in a default OS X install.

Getting a Botan library test program to compile under Windows 7 (MinGW, Code::Blocks)

I have been trying in vain to get this test program to compile
#include <botan/botan.h>
int main()
{
Botan::LibraryInitializer init;
}
I have downloaded library source from the website. I ran configure.py, which ran fine.
I then attempted to run MinGW-make
This is the error I got
c:\Botan-1.11.7>mingw32-make
g++ -m64 -pthread -fPIC -fvisibility=hidden -std=c++11 -D_REENTRANT -fstack-pro
tector -O3 -momit-leaf-frame-pointer -Wall -Wextra -Wstrict-aliasing -Wstrict-ov
erflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual -Wold-s
tyle-cast -Wzero-as-null-pointer-constant -Ibuild\include -c C:\Botan-1.11.7\src
\lib\algo_base\scan_name.cpp -o build\obj\lib\src_lib_algo_base_scan_name.obj
C:\Botan-1.11.7\src\lib\algo_base\scan_name.cpp:1:0: warning: -fPIC ignored for
target (all code is position independent) [enabled by default]
C:\Botan-1.11.7\src\lib\algo_base\scan_name.cpp:1:0: sorry, unimplemented: 64-bi
t mode not compiled in
mingw32-make: *** [build\obj\lib\src_lib_algo_base_scan_name.obj] Error 1
I searched Google and any available forum I could find. I found prebuilt libraries for windows in a hidden folder on their site. However the package contained lib and dll files and not .a files which MinGW requires. I tries to use a program LIB2A which created a .a file. I have added this file into my code::blocks linker options. I also included the include folder.
When I try to compile I get this error.
C:\botan\include\botan\init.h|41|undefined reference to `_imp___ZN5Botan18LibraryInitializer10initializeERKSs'|
It seems like it cannot see the library with function definitions, but I am lost on where to go from here.
mingw32-make has the -m64 flag set, which means it's trying to build a 64 bit library. To build a 64 bit library, you'll need to get MinGW-w64.
When you ran configure.py, it likely set up your MakeFile to build a 64 bit library. You'll want to check what options are set in its output. This includes the option to build 32 bit or 64 bit. Either way, you'll want some variant of this: python configure.py --os=mingw --cc=gcc
This question had a similar error, and suggested using MinGW-w64, which will allow you to build a 64 bit library: Building 64 bit dll with MinGW 32 bit in Eclipse
In order to build with mingw32-make off the command line, you'll need to also add the MinGW-w64 bin directory to your Windows path, and likely remove the Code::Blocks packaged MinGW from your path to avoid conflicts. You'll still use mingw32-make to build the library with MinGW-w64; even though it's named mingw32-make, it will build 64 bit.
If you decide to build the library 64 bit, you'll need to build your application 64 bit as well, so you'll want to set up MinGW-w64 for Code::Blocks. To set MinGW-w64 up in Code::Blocks, see this question: Setting up MingW and Code::Blocks in Windows 8 64 bit.

QT5 attaching project name with every sourcefile name, compiling error

i want to get started with QT. I donwloaded QT5 MINGW compiler with QT creator and i am trying to build the pre attached example named affine the problem is that the QT5 i think embed the project name with each of source file and thus gives error that file not found. some thing similar
:-1: error: ..affinemain.cpp: No such file or directory
while the file name is just
main.cpp
i don't know how to fix it. I searched lot on internet but could not found anything useful.
I even try to compile from command prompt but i am not fimmiliar with command prompt compiling as i am new to QT and previously i am totally developed with IDE in visual studio and eclipse for java so i have no idea about the make file and compiler command line arguments.
could some body please help me to fix this issue and can you tell please why compiler attaching project name with the source file name?
Thanks in advance
I have got the same problem and my solution may help you.
I am working with Qt5.0.1 now, and there are two distributions to work on windows with it: Qt5.0.1-mingw and Qt5.0.1-msvc2010.
I had to use mingw and there was a problem on my setup that "/" is ignored in path's.
So according to Qt Creator, compiler was called to process file mainwindow.cpp and this file was passed to it
g++ /*truncated*/ ..\qt-example\mainwindow.cpp
Below is the full compiler input:
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN -I..\qt-example -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtWidgets" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtGui" -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtCore" -I"debug" -I"." -I"." -I"..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\mkspecs\win32-g++" -o debug\mainwindow.o ..\qt-example\mainwindow.cpp
And the error produced.
g++.exe: error: ..qt-examplemainwindow.cpp: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.
So, we can see that "\" is ignored by the compiler and file name is merged with directory name.
The solution to that problem goes to the tools that are used - MinGW (Minimalist ports of GCC and Binutils). And also MSYS - a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. In our case - g++.
MSYS is not shipped with Qt5.0.1-mingw and g++ is not using it, but having MSYS available in your PATH environment variable breaks the system.
MSYS is used for git scm, which I have installed, so my path contains links to MSYS that goes bundled with git. So I have next paths in my PATH environment variable.
C:\Program Files (x86)\git\bin;C:\Program Files (x86)\git\cmd
I have not found how MSYS is used by Qt Creator or g++, or where it is linked, but when I have dropped next path from PATH:
C:\Program Files (x86)\git\bin;
and restarted Qt Creator - g++ succeeded on compiling my file, it worked.
The question why/how it influences the Qt Creator/g++ that should not use MSYS utils installed with git is still open.
i canĀ“t comment.
important : delete all the files in the release and debug folder (compiled version) before try the tips of the autor ...