Link glew.lib as a static library with eclipse - c++

I am a newbie in C++, I made many searches before I ask, I started OpenGL tutorial with C++ , I am using eclipse with GNU cross compiler, I know how to like static libraries with libXXX.a format then I want to use GLEW library, I have its source code and a precompiled version for windows which is libglew32.lib, if I use make to compile the source code I get an error which is
make (e=2): The system cannot find the file specified.
Makefile:131: recipe for target 'tmp/cygwin/default/shared/glew.o' failed
make: *** [tmp/cygwin/default/shared/glew.o] Error 2.
if I put the library in the libraries folder and add it to the linker as I do with other libraries I get errors in compiling the project like undefined reference to 'glewExperimental' or Invalid arguments 'Candidates are:void glfwMakeContextCurrent(*)'
so I have 2 questions:
how can I compile the source code correctly to a static library which I can use in eclipse.
can I add .lib files to use with eclipse? if yes, how can I do?

I compiled it using gcc and lined by ar finally I get the libglew.a

Related

Which files shoud I copy to my project to use ImageMagick? or How to compile ImageMagick with MinGW on Windows?

My question might look a little simple because I am new with QT and C++ but I was struggling with this for a day, so I decided to ask someone for help. I am trying to use the ImageMagick library in my QT-MinGW C++ project to convert between different image types. I downloaded the source code from here and followed the described steps to build it:
./configure
make
make install
Now I can use commands such as convert, magick and etc. in the command line, but How should I add the library to my QT project? There is no .dll and \include folder. Which files should I add to my project? Where is the library file?
Note: I would like to use the library in the Windows environment. I am using Windows Subsystem for Linux to compile it.
Note 2: I have tried to compile with MinGW MSYS on windows but I got thousands of warnings plus error : c:\ImageMagic/MagickCore/nt-base.c:2774: undefined reference to SetDllDirectoryW' collect2.exe: error: ld returned 1 exit status make[1]: *** [MagickCore/libMagickCore-7.Q16HDRI.la] Error 1.
Desperately need for help.
If you have built ImageMagick with MinGW as both static and shared libraries you should have these .a files in the lib folder:
libMagick++-7.Q16HDRI.a
libMagick++-7.Q16HDRI.dll.a
libMagickCore-7.Q16HDRI.a
libMagickCore-7.Q16HDRI.dll.a
libMagickWand-7.Q16HDRI.a
libMagickWand-7.Q16HDRI.dll.a
and something like these .dll files in the bin folder:
libMagick++-7.Q16HDRI-4.dll
libMagickCore-7.Q16HDRI-7.dll
libMagickWand-7.Q16HDRI-7.dll
If you don't have the .dll.a and .dll files then you don't have the shared build.
If you built ImageMagick yourself and the shared libraries are not built, it could be because the dependancies are also missing their shared libraries.

Compiling LZ4 compression library on Windows

I'm trying to use the LZ4 compression library with a C++ project in Visual Studio 2013. I need to build the .dll files for it so I can link it in the project. I'm trying to use mingw to build it with the make file, but that is throwing unpleasant errors. Navigating to the base directory of the repository and running mingw32-make.exe gives the following error output:
process_begin: CreateProcess(NULL, uname, ...) failed.
The filename, directory name, or volume label syntax is incorrect.
Makefile:72: recipe for target 'lz4programs' failed
mingw32-make: *** [lz4programs] Error 1
I'm not overly familiar with compiling make files on Windows, and am having difficulty with figuring out what's causing the error. Additionally, in something that I find rather odd given how popular this compression library is, I cannot find any information online about compiling it for Windows. Any assistance in getting this thing to compile would be greatly appreciated.
I was able to use CMake with the CMakeLists.txt file in the cmake_unofficial folder to compile the library and the lz4 executable.
The solution is compiling a static version of the library. If you want a dll version, you should be able to experiment with the Visual Studio settings to get the dll if the static library isn't sufficient.

Boost library eclipse linking error

I'm working on windows 7 and eclipse juno. In my project i have linked correctly header-only boost libraries, and i need only two compiled libs ("libboost_signals-mgw46-mt-1_54.a" and "libboost_signals-mgw46-mt-d-1_54.a"). I added them to the MinGW C++ linker in the same way is explained here Linking Boost to my C++ project in Eclipse. The path i have specified in "Library search path" for the linker is "C:\MinGW\boost_1_54_0\stage\lib" (where compiled libraries reside) and the libraries themselves are added with their names except the ".a". But when i try to build the project i get this error:
Info: Internal Builder is used for build
g++ "-LC:\MinGW\boost_1_54_0\boost" -o Ccccc.exe "src\Ccccc.o" -llibboost_signals- mgw46-mt-1_54 -llibboost_signals-mgw46-mt-d-1_54
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find - llibboost_signals-mgw46-mt-1_54
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -llibboost_signals-mgw46-mt-d-1_54
collect2: ld returned 1 exit status
The code is irrelevant because in order to solve this problem i try to add those libraries to a simply "Hello world" project. Thanks for any help, sorry for my english.
Just a wild guess but try omitting the lib from the library name to see if it can find the library that way. Otherwise, clearly the library cannot be found in your library path.

Eclipse CDT and OpenCV issue

I'm trying to make OpenCV work in Eclipse CDT, provided that I'm using the following under Windows 7:
I have set the path for Includes under Cygwin C++ Compiler as follows: C:\OpenCV2.2\include\opencv
And, also set the path for Libraries under Cygwin Linker as follows: C:\OpenCV2.2\lib
When I try to build the project, I get the following two errors:
cannot find -lC:/OpenCV2.2/lib
make: *** [OpenCVDemo.exe] Error 1
Any ideas why am I getting that?
Thanks.
You need to add C:\OpenCV2.2\lib as a library path, not a library. Add libraries that you will use:
opencv_core
opencv_highgui
etc.
Also you may need to use include directory C:\OpenCV2.2\include\opencv2 and #include <opencv.hpp>.

Boost autolinks libraries which are not built by Boost, but the intended ones are built

I am developing a Math application which can be extended by writing python scripts.
I am using Qt 4.6.3 (built as static library, debug and release versions) and Boost 1.43.0 (built as static library, runtime-link also set to static, multi-threaded version, debug and release). Everything is built with MSVC++2008. Boost built the following libraries:
libboost_python-vc90-mt-s-1_43.lib
libboost_python-vc90-mt-s.lib
libboost_python-vc90-mt-sgd-1_43.lib
libboost_python-vc90-mt-sgd.lib
My project compiles, but gives the following error during the linking phase:
1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'boost_python-vc90-mt-gd-1_43.lib'
Why is it not selecting one of my compiled libraries?
I think the s in the library names stands for static, but then the auto-linking feature seems to select a dynamic library, and I want it all linked statically in one executable.
The same happens with the regex library: I have the same 4 regex libraries compiled and a quick test shows this linking error:
1>LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc90-mt-gd-1_43.lib'
What to do?
You can define BOOST_ALL_NO_LIB. This prevents automatic linking of boost libraries and you must then link the required boost libs manually.
If 's' stands indeed for static (I don't know all those modifiers by heart), define the BOOST_ALL_DYN_LINK symbol while compiling (add it to the command line options). It tells boost to link to the DLL libraries. Alternatively, compile/install static boost libraries.
The problem is fixed, during the compilation of the boost libraries, I selected the link=static option. Which creates static libraries. I also selected runtime-link=static option, and this was wrong!
The solution for this problem was compiling boost with runtime-link=shared. Now some extra libraries are added, with the correct filenames, so the linker can find them. At first the compiler still searches for the dll library (boost_python-vc90-mt-gd-1_43.lib, instead of libboost_python-vc90-mt-gd-1_43.lib), everything else from boost links automatically to a static library, but because boost.python has a different auto-linkage set up, when you provide BOOST_PYTHON_STATIC_LIB, it finally links to the right library and it works!