I follows the CMake org and this one attempt to load the library but failed.
I have use make install put GLFW to /usr/local/include/GLFW/, and then, I add the directory to Link Binary With Libraries in XCode project.
But #include <GLFW/glfw3.h> said the file not found.
How to load the library? thanks
It's my first time use cmake, I mess all things. To import the library should add /usr/local/include/ to Header Search Paths and add /usr/local/lib/ to Library Search Paths, besides, Link Binary With Libraries should add libglfw3.a in /usr/local/lib/.
import with #include <GLFW/glfw3.h>
Related
I followed many tutorials to get boost installed, firstyly I downloaded boost and added path with:
path=%path%;
c:\program files (x86)\code block\mingw\bin
secondly I ran
bootstrap.bat gcc
and then
b2 toolset=gcc
but there is no such lib installed as UUID which I really need to my project. Is there any way to make it happen as I haven't found any specific help among all those topics and I'm getting really confused. I'm working on win10 if that makes any difference.
Did you read documentation?
Boost UUID library is header-only library. See Configuration:
The library does not require building or any special configuration to be used.
So you have to download boost library and unpack it to some place in your disk (for example to c:\boost). Path to boost library will be c:\boost\boost_1_62_0. Then you have to specify the compiler the place where the boost library is located. It is compiler or IDE specific way. But the common way is to use "Additional Include Directories" option of compiler. It is -I for GCC and /I for MS VC++. Last step is to write include directive in your c++ code. For example:
#include <boost/uuid/uuid.hpp>
For code example see Example and files in boost/libs/uuid/test/ folder
I'm trying to compile a simple Boost Wave example and while Xcode is recognizing the headers, it is giving me a slew of Apple Mach-O Linker(Id) Errors. I have encountered this before and I don't remember how I solved it. Please help!
I have attached a screenshot.
P.S. I have Boost 1.57.0 and it works just fine with any Xcode Project. For whatever reason, though, it isn't in the case when it involves the header boost/wave.hpp like so...
#include <boost/wave.hpp>
Also, I ruled out the body of the code as a culprit. This throws the linker erros:
#include <boost/wave.hpp>
int main() { return 0; }
Other Boost headers like these, do not:
#include <boost/function.hpp>
int main() { return 0; }
I figured it out, but have no idea why this is the case. If anyone would like to add an explanation, that would be splendid. I had to manually add the various dynamic and static libraries referenced in each of the above issues. I attached a new screenshot so others having this issue can see the end result.
Well, the explanation is very simple. In order to be able to build your project, the compiler working under the hood needs to know:
Where to search for the #include <..> within your project's files: this corresponds to the -I directory option for the g++ compiler. In Xcode this corresponds to set the "Header Search Paths" in the Build Settings of you project.
Without specifying the Header Search Paths, you will get errors on the #include lines since Xcode doesn't know where to look for those included files.
Where to search for the library that must be linked to your source code while building the project: this corresponds to the -L directory option for the g++ compiler. In Xcode this corresponds to set the "Library Search Paths" in the Build Settings of you project.
Without specifying the ** Library Search Paths**, you will get errors while trying to build your project since Xcode doesn't know where to look for the linked libraries.
What libraries must be linked to your project files at compilation time: this corresponds to the -l linking option for the g++ compiler.
In Xcode this corresponds to add the .dylib files to the Link Binary With Libraries in the Build Phases settings of your project. Note that you don't need to add manually the libraries to the main folder of your project, the last described step suffice.
See here and here for the directory and linking options of the g++ compiler, respectively.
I have included the boost library in a Codeblocks c++ project.
Now, in the file
boost/function.hpp
there is an include statement
#include <boost/preprocessor/iterate.hpp>
However I get this error in Codeblocks when I try and compile:
/home/arvind/Documents/Workspace/Browser/boost/function.hpp|15|fatal error:
boost/preprocessor/iterate.hpp: No such file or directory|
What am I doing wrong here? I have simply included the Boost library as it is.
Also, I cannot find the screen/option to set the main class (which will actually execute).
How do I do this?(I am new to CodeBlocks hence this question).
Your boost includes seem to be in a non-standard/system directory : /home/arvind/Documents/Workspace/Browser, you must tell the compiler to look there (gcc -I command-line switch).
Go to Project->Build Options->Search Directories->Compiler and add the directory where boost includes are. I don't have a codeblocks install right here so this was from here.
If you can, I would recommand installing boost on your system once and for all instead of just copying files in your codeblocks workspace.
// brief version
How can I make CMake to use my supplied zlib (which it also has to build from source) instead of the one found by the finder without breaking the finder for other libs (OpenGL)?
ZLib needs to be used by the main project and also libPNG which comes as source as well.
Primary target platform is Windows.
// longer version:
In my project I need to link against libpng, zlib and OpenGL. With libpng being dependent on zlib. But zlib is also required by the main project.
I need to supply sourcecode for all libs except OpenGL, and build those libraries along with
the main project to assert linking the correct version and simplify building on Windows.
I found ways to do all this with custom libraries where no built-in finder exists, but I can't override the finder properly for just zlib. If I change the search path for libs, then OpenGL is not found.
However I can't get cmake to use my supplied zlib instead of a rouge zlib.DLL that the package finder finds somewhere in my system. (The one from tortoise git)
I tried to set ZLIB_LIBRARY to a specific filepath, but that only works on MinGW, and I also think this is not the way to do it.
(And also I had to explicitly link to png16_static instead of just libpng, for an inexplicable reason.)
Any help on this is much appreciated. Maybe I'm taking this on the wrong way?
Target&Development Platform:
Windows7
Visual Studio 2010
and MinGW (both need to work)
My (simplified example) CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (MyProject)
find_package(OpenGL)
add_executable(MyProject main.cpp)
include_directories(${INCLUDE_DIRECTORIES} "${PROJECT_BINARY_DIR}")
include_directories(${INCLUDE_DIRECTORIES} "external_libs/lpng162")
include_directories(${INCLUDE_DIRECTORIES} "external_libs/zlib-1.2.8")
include_directories(${INCLUDE_DIRECTORIES} "${PROJECT_BINARY_DIR}/external_libs/zlib-1.2.8")
add_subdirectory("external_libs/zlib-1.2.8")
link_directories(${LINK_DIRECTORIES} "${PROJECT_BINARY_DIR}/external_libs/zlib-1.2.8")
# libpng will not build correctly if this not set
set (ZLIB_ROOT "${PROJECT_SOURCE_DIR}/external_libs/zlib-1.2.8")
# manually set this to prevent cmake from finding the tortiose-git zlib.dll first
# DOES NOT WORK CORRECTLY, only with mingw32
set (ZLIB_LIBRARY "${PROJECT_BINARY_DIR}/external_libs/zlib-1.2.8/libzlib.dll")
add_subdirectory("external_libs/lpng162")
TARGET_LINK_LIBRARIES(MyProject png16_static zlib ${OPENGL_LIBRARY})
Project (simplified example) structure:
./main.cpp
./CMakeLists.txt
./external_libs/zlib-1.2.8/ <- contains respective source
./external_libs/lpng162/ <- contains respective source
Third-party libraries most likely call FindZLIB.cmake to determine the location of CMake. You already had the right idea by setting the ZLIB_LIBRARY manually, but were not quite getting it right:
add_subdirectory(<path_to_zlib_src_dir>)
set(ZLIB_INCLUDE_DIR "<path_to_zlib_src_dir>" "${CMAKE_BINARY_DIR}/<path_to_zlib_build_dir>")
set(ZLIB_LIBRARY zlib)
add_subdirectory(<path_to_lpng_src_dir>)
The include directory needs to contain both src and build path as zconf.h is build by CMake
The library name is only the CMake-target name, not the complete path to the resulting file.
On Windows dlls are not automatically copied by CMake. You might want to add some additional code to make sure that the zlib and lpng dlls end up in the right place.
You can call find_package(zlib) yourself to make sure it behaves as expected
In the rare case that a third-party lib does not use the find script, you will have to dig into that project's CMakeLists to find out what is going on
I have trouble compiling boost process library using bjam. I downloaded the newest version (0.5) and copied the headers and lib folders to boost main directory. Then I called bootstrap, and "bjam --with-process" but I get an error complaining that the library process is not found.
bjam --with-process
error: wrong library name 'process' in the --with- option.
This library is header-only. You don't need to build it - just #include the appropriate headers.