Build C++ library on OS X/Mac using Qt - c++

I have created a C++ library on Windows using Qt and it works well. Now I want to build the same C++ library on OS X/Mac using Qt, and after running the same steps as how I made this C++ library on Windows, I’m not sure which generated files is the library I need on OS X.
On Windows, I can use the library in other C++ project through the following files: .dll, object file library and the header file. I can find the first two files generated in the target folder:
But on Mac, after checking the same folder I found the generated files as below:
Which files are the library that I made? And how to use the generated library in other C++ project on OS X?
I try to find some step-by-step guide but with no luck so far, so if there’s any useful link that will be of help.
Thank you in advance!

The library is
libsdk.1.0.0.dylib
all other libsdk*.dylib are links to the library (compatibility reasons, some applications look for libsdk.dylib). You use these library as you would use any other dynamic library. Supply the library and the header files to the local path or install them system wide (DYLD_LIBRARY_PATH).
See How to use dylib in Mac OS X (C++) for more information.

Related

How can I add libraries to a project in a system independent way?

I'm developing an application using Qt and OpenGL, and found it necessary to download the GLM library. It's a header-only library, so I don't need to link to anything. I want this application to build on any system that has the correct libraries installed. My problem is that I don't know where to put GLM so that the system can find it without adding a specific path to the project's .pro file. The .pro file is part of my git repository, which is how the source is distributed to other systems like Linux, etc. So I don't want this file to specify the exact location of GLM because other systems could have it in other places.
I'm currently developing on Windows, compiling in Qt Creator using Visual C++ 2010. I read from MSDN that #include <file> searches using the INCLUDE environment variable, so I tried to add the path to glm.hpp to INCLUDE, but QtCreator's build environment for this project seems to overwrite INCLUDE. So I appended the path to GLM to the new INCLUDE from within QtCreator's Projects tab, but my code still can't find glm.hpp.
In general, how can I add an external library to my system such that my compiler will be able to find it without specifying the exact location in a project file that's distributed to other systems?
What you need is a build system with the power to search the system for the libraries you request, and be able to do so on any platform. One such build system is cmake, and it is the most widely used build system. In essence, cmake allows you to write a build script in which you can specify all the things you normally specify when creating a project in Qt Creator or Visual Studio, like the list of source files, grouped by targets to compile (libraries, executables, etc.), the relative paths to the headers, and libraries to include for linking and for include-paths, amongst many more things. For libraries that are installed on the system, there is a function, called find_package() (part of cmake script commands), that will find out if the library is installed and where to find its lib files and headers (storing those paths as cache strings that you can specify on the targets and such). It usually works great, as long as the libraries are not installed in weird places. The way it works is that when you run cmake, it will generate a build script/configuration for almost any platform you specify, and then you use that to compile your code. It can generate makefiles (Unix-like or windows), CodeBlocks project files, Visual Studio project files, etc.. And many IDEs also have native support for cmake projects.
I wish I could recommend an alternative, just to sound less biased for cmake, but I haven't heard of any that truly compare to it, especially for the purpose of locating external dependencies and working with different platforms. I would guess Boost.Build is decent too.

How do I compile libnoise on Mac OS X Mountain Lio

I am new to the Mac OS X environment when it comes to compiling linux based libraries. Whenever I used a library i just downloaded the .framework file, added it to my /Library/Frameworks and included it in my XCODE project, and all was fine.
Now I am stuck with libnoise. I want to use it on my project and I have no idea how to generate the .framework file/directory.
Can you help me please?
If you have libnoise, most likely it contains some sort of a Makefile or a configure script.
By running the
./configure
make all
you will get the library file (libnoise.a) for your platform, the OSX10.8.
Framework is essentially a folder with specific layout and a .plist file. To generate such a folder automatically, you may create an expty Xcode project of the type Framework and add the libnoise.a you've just created as a linker's input.
There is a detailed instruction on how to create the Framework from static libraries (.a files): http://www.blackdogfoundry.com/blog/creating-a-library-to-be-shared-between-ios-and-mac-os-x/
You might be missing the header files in you framework, but then can be also added to the Xcode project from libnoise sources.
This SO answer may be of use also: Difference between framework and static library in xcode4, and how to call them
Apple's documentation is also good: https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html
I'm not entirely sure if this is what was meant by "with a different fork and cmake"
but I got libnoise to run in my mac using this git repo.
https://github.com/qknight/libnoise

Using libcurl without installing it

How can I use libcurl with my project without actually installing it or curl on the system?
I want to make my source-code portable, so that any developer can copy the folder with all sources and other files, run make and compile the program without the need for system level installations.
I am looking for (probably separate) solutions for Linux and for Windows (dll?). If it is possible, provide some standard/official solution and not hack (I'd like to be educated about linking third party libraries)
I've used it on Windows using Visual Studio, all you need to do under Windows:
Download the source
Using CMake generate the project files (when using Visual Studio).
Build the libraries, 3 files will be built: libcurl.lib, libcurl_imp.lib and libcurl.dll
Include curl.h in your project and add the paths to your .lib files
Build your program, put libcurl.dll in the executable folder and it will work.
On Linux it should be a similar process, build the libraries and include them with your source.
You probably want to build a static library out of libcurl and link agains it. Should be pretty straightforward and the process is almost identical on every OS.

including boost source files in project using eclipse

I am using boost libraries in an application which is targeted for multiple platforms including android.
unfortunately boost libraries are not included in android so i am trying to include the boost source files in project and compile them but i am getting many errors when i am trying to do that mostly unresolved symbols in many files
i have created the project as a shared library using eclipse ide and os is ubuntu 11.10
please help and i am not really a nerd so easy to understand solution would be really helpful.
Thanks in advance
make a folder called local/include/ in your home folder. Then create a symbolic link from /usr/include/boost to there. Include ~/local/include in the LOCAL_C_INCLUDES variable in your Android.mk. This will work for the header-only libraries in boost.

How can I use boost::test with xcode 4 for testing some ios c++ code?

I would like it to operate similarly to how the normal test framework works - if you the tests from the Product->Run tests menu item, the output should appear in the left sidebar window.
I found a guide for using xcode 3 with boost test, but couldn't figure out how to translate those instructions for xcode 4 (if it is even possible).
Finally, I'm building an iPhone application. I could get boost running using the #include <boost/test/included/unit_test.hpp>, however it is pretty slow. Using the standard #include <boost/test/unit_test.hpp> results in link errors due to the library being built for the wrong architecture.
You should build the boost library to a static library ".a" using .configure and make.
According to this:
No special build options or macro definitions are required to build
the static library. Using the Boost.Build system you can build the
static library with the following command from libs/test/build
directory:
bjam [-sTOOLS=] {-sBUILD=boost_unit_test_framework}
This library or libraries and their respective headers need to be added to the project. (Two built versions are needed, one i386 for the simulator and one ARM for devices).
The static library is imported from Link Binary with Libraries in
Build Phases.
Also you need to tell XCode which of these to use, you
can do this by setting contidional build settings in `Build settings-
Library search paths. Above this line is where you add the Header
Search Path to the boost header files.
After this you should be able to include the headers (Added above) in C++ or objective-C++ code of yours. (To make Obj-C files Obj-C++ files you need to change all deppendent .m files to .mm)
If there is a some problems after this, switching Compiler or standard library for C++ in Build Settings might help.