So I've installed gpp-compiler extension for Atom, I've put glut.h into my MinGW\include\GL directory as well as I've put libglu32.a file into my MinGW\lib directory and also I didn't forget to put glut32.dll,glu32.dll into C:\Windows\System32 and I've also put glu32.dll into C:\Windows\SysWOW64.
This is the compiler configuration I've got:
settings
And that's the compiling error I'm getting:
b:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lglut32
collect2.exe: error: ld returned 1 exit status
Looking forward to your answers :)
The linker is not able to find the library glut32.a.
You need to add the folder via
-L<folder containing glut32.a>
to your C++ compiler command line options, where you already declared the libs which shall be linked to your application.
Related
I am trying to compile a simple project which uses one of my headers. I am on Windows and I am using MinGW-W64-builds-4.3.5 Suppose the project is called test.cpp and I want to compile it using my headerosmanip which requires also the linking of its created static library libosmanip.lib. The static library has been compiled and created in MSYS2 and then copied into Windows filesystem. If I try to compile with:
g++ -std=c++17 -losmanip .\test.cpp
To search for the system headers and library path I did:
g++ -v test.cpp
and decided to put headers into C:\MinGW\bin\..\lib\gcc\i686-w64-mingw32\8.1.0\include\c++ and the static library into C:\MinGW\lib\gcc\i686-w64-mingw32\8.1.0\.
I got the following error:
C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe:
cannot find -losmanip
collect2.exe: error: ld returned 1 exit status
I've tried also by adding the -L option, linking the library path, or editing the LIBRARY_PATH variable ( $Env:LIBRARY_PATH+=";C:/MinGW/bin/../lib/gcc/i686-w64-mingw32/8.1.0/"), but it still doesn't work.
I tried to move the library into the same folder of the test.cpp file and compile, but again the same error occurs.
It's strange because I tried same thing on Ubuntu, MacOS, MSYS2 and Cygwin64 and it works.
Can you help, me please?
I finally solved the issue. The problem was related to the fact the the suffix of my library was .lib. By changing it in .a and rebuilding the library passing the correct static library name to the ar command the problem disappeared.
I was trying to install STXXL library to a custom path following this answer supplying prefix to cmake this way:
cmake -DCMAKE_INSTALL_PREFIX=/usr . && make all install
When I run the tests, they seems to be working fine. But I want to include STXXL in a different MakeFile and compile that project. In that MakeFile there a line
STXXL_CONFIG = /opt/stxxl/stxxl.mk
I believe the configuration file stxxl.mk comes from the old make based installation (I couldn't locate it in my system either). I was wondering how I can modify this file to include STXXL library and get the custom project compiled.
Without modifying the above statement in MakeFile, I am getting the error:
undefined reference to 'stxxl::get_next_seed()' collect2: error: ld returned 1 exit status
It goes without saying that I don't have root access and unfortunately, neither a good background with MakeFiles. This is not a duplicate of Makefile with STXXL
To use a third party C++ library from a non-standard location in GNU Make the regular steps are:
Add the path to 3rd-party library headers to your C++ preprocessor flags. E.g.
CPPFLAGS += -I/3rd-party/include
Add the path to 3rd-party shared/staric library to your linker flags and the library itself. Assuming the library is named lib3rd-party.so or lib3rd-party.a, e.g.
LDFLAGS += -L/3rd-party/lib -Wl,-rpath=/3rd-party/lib -l3d-party
I am trying to compile the Dlib library in Eclipse, but have an error in linking.
According to: http://dlib.net/compile.html I have to include the path containing the dlib folder (that's what I did) and include the source file in my project: dlib/all/source.cpp.
I keep on getting the following error:
../source.cpp:7:41: fatal error: ../base64/base64_kernel_1.cpp: No such file or directory
This is a line from the source.cpp file. The directory looks like:
/usr/include/dlib-18.6/dlib/base64, If I add that path in my library I get the next error:
In function dlib::threads_kernel_shared_helpers::thread_starter(void*)':
/usr/include/dlib-18.6/dlib/base64/../threads/threads_kernel_2.cpp:37: undefined reference topthread_detach'
Do I have to keep adding paths after each error?
Why doesn't Eclipse just add all subpaths of my /usr/include/dlib-18.6/ (that's the path containing dlib and the it's the path I added)?
I think it depends a bit, on how you had setup your particular toolchain, to build your main/dlib project.
Building using e.g. GCC 4.8 (and using the -std=c++11 option) might require to specify the -pthread option on linking stage, other environments might want to link against -lpthread.
I'm using CodeBlocks (the latest version, I'm not sure what that is at the moment)
I'm trying to use fallahn's SFML Tiled map loader, and so far I've successfully statically linked SFML and included the map loader files in my source as well as added it to my search directories, however, I'm having trouble linking zlib (which the map loader uses)
I'm gonna go ahead and walk you through how I linked zlib because I'm not even sure which step I messed up on:
obviously, I went on over to http://zlib.net and grabbed the latest version (1.2.8)
I unzipped it to my desktop
I went into my project's build options and initially i thought "I'll just globally set up my search directories like before" (for SFML and the map loader, there was an 'include' and 'lib' folder, i put 'include' in the compiler search directory, and 'lib' in the linker search directory), except there were no folders named 'include' or 'lib' in the folder that i got from unzipping. This is where I simply included the whole folder I unzipped (I'm pretty sure that's terrible practice but I wasn't sure what else to do)
I compiled an example from the Map loader's source files, and got an error along the lines of 'undefined reference to inflate' on 4 different occasions. I already figured at this point that I made an error while linking, so that's when I took to google. Most answers were simply "add -lz" or "link libz"
Well, I don't know what "add -lz" means.. like at all, so I just linked "libz", then my compiler gave me the error "ld.exe cannot find -lz", which led me to the assumption that linking libz and adding -lz are the same thing.
Here are some things I don't understand at all, and if you can't explain what they are, please at least explain how to blindly do it:
1. Compiling a library
2. Anything to do with make files, I don't know what they are or what they do at all
3. Adding commands to the project command-line.
Build messages:
C:/Documents and Settings/Brenda/Desktop/sfml-tmxloader-master/src/MapLoaderPrivate.cpp:834: undefined reference to inflateInit2_'
C:/Documents and Settings/Brenda/Desktop/sfml-tmxloader-master/src/MapLoaderPrivate.cpp:843: undefined reference toinflate'
C:/Documents and Settings/Brenda/Desktop/sfml-tmxloader-master/src/MapLoaderPrivate.cpp:852: undefined reference to inflateEnd'
C:/Documents and Settings/Brenda/Desktop/sfml-tmxloader-master/src/MapLoaderPrivate.cpp:881: undefined reference toinflateEnd'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 10 seconds)
4 errors, 0 warnings (0 minutes, 10 seconds)
The issue is, that zlib doesn't provide binaries for MinGW directly, they only provide *.lib, *.def and *.dll files, but in order to link with MinGW/GCC, you'll need an *.a file.
Since zlib is a C library the ABI will be identical and thus you can "simply" convert it, for instance with the help of lib2a. While this should work, it might still be better to download the source code and build zlib yourself, since it ships with a CMake file, it's rather easy to build.
I am using Eclipse Galileo 3.5 with CDT 6.0
I am having a problem in including the header files located in c:\cs106 ... I searched on google and found that I have to go to Project Properties > C/C++ General > Paths and Symbols and in GNU C++ I have added the path c:\cs106
And eclipse is able to find them now but the other problem I am getting is that when I try to build a simple program which is using a function defined in "simpio.h" located in c:\cs106 and I have already included at the top of my program #include "simpio.h" but it is giving me an error
**** Internal Builder is used for build ****
g++ -IC:\cs106 -O0 -g3 -Wall -c -fmessage-length=0 -osrc\CS106.o ..\src\CS106.cpp
g++ -oCS106.exe src\CS106.o
src\CS106.o: In function `main':
C:/Users/User/workspace/CS106/Debug/../src/CS106.cpp:8: undefined reference to `GetInteger()'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 986 ms.
I googled and what I get is that I have to to tell the linker for a .lib file that is accompanied with the header files. in my case the provided .lib file is (CS106CPPLib.lib) and I checked with the project file that I got was of VS 2008 and saw that they have added the following statement in the project settings file under
VCLinkerTool:
AdditionalDependencies="c:\cs106\CS106CPPLib.lib winmm.lib"
So I think I have to include this CS106CPPLib.lib winmm.lib in eclipse as well but I am unable to figure out where should I do this. Please if someone can help me I will be really grateful.
If you need any more info please reply me.
Thanks
It looks like a linker error, it has nothing to do with the header. You now need to link the library in eclipse.
you need to define explicitly library's name in your project... in project setting somewhere
if you already done that... that function is not there in library... Probably you need to add another lib file in which function's definition is there...