C++ Standard for dynamic Libraries on Windows and Linux [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
where can i find examples of how to create one basic c++ project that uses dynamic shared libraries on windows and linux?
I need just of a simple example with one .cpp and .h file for the shared library and one for the program.

This is a very difficult topic. Shared libraries have very different setups and small variations among platforms.
My recommendation is that you use one tool to generate the shared library for you with the appropiate flags.
I recommend you to use one of this, and in this order, if you only want to compile for windows and linux:
WAF
CMake

Related

What files have to shipped with the actual program? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I know these are the include files(in c++) We have to compile them and then have to ship them with the actual binary. But I have a bit strange problem.I used windows.h in a program and I want to ship it but windows.h have other include files and so on.So I would have to ship whole windows sdk in the form of dll's .Is there any other way to do it?
You do not need to ship header files with a binary application.
You do however need to ship any shared libraries (DLL's on Windows) that your program depends on - and this includes the compilers runtime (the standard library etc) - static libraries are made part of the executable and thus do not need to be shipped separately.
If you are using Visual Studio then you need to ship the Visual Studio redistributables along with your program (google the version for your Visual Studio version) - for other compilers there are similar requirements.

What to compile as a library? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've lost my head just a little trying to reason the most effective means of compiling a c++ project. I stick to more managed languages like Java so the CMake file is a bit obtuse to me.
My main problem is what do I compile as a library and what do I just compile together? I have a main function in my program with various over classes in different files with headers. What is the most normal way of handling these files together? Should I compile the main function separate from the classes then link them or should they be a shared library even though it is a bit small for a library?
Mainly I am looking just for general guidelines of what should be compiled together, what should simply be linked, and someone to more clearly explain the norms/best practices of how this all works.
I understand that the compiler needs to convert the Header and Source files to object files and then combines them together as a binary. I am just confused at what should go into the binary.
If you need the code for only one executable you can just link all object files together. Libraries are useful if you need the same functions/object files in different executables.
Of course the bigger a project gets you could also use sub projects which output libraries and then link the main project files and the sub project libraries together.

Install OpenCV on a C++ compiler [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am used with using OpenCV with python. But does someone have an idea how to add openCV library to a C++ compiler (such DevCpp or CodeBlocks...).
If there is a compiler on which it's easier to install OpenCV library no problem, I have no restriction conserning the compiler.
I followed some tutos on the net but they were not so clear.
Thanks.
C++ has two important phases of compilation. First, each individual .cpp file is needed. You need the library header files (.h) for this. Secondly, the separate parts are linked together, and you need the library files themselves. (.lib/.a depending on platform).
So, you need to provide paths to both. The compiler knows which exact headers are needed from the #include statement, but the libraries to link must be explicitly listed.

What's the best way to distribute the header files of my C++ shared library? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
So I have my shared library libMySharedLibrary.so. And it has a bunch of header files in their own folders, etc. What is the best/standard way to group those header files and distribute them to the clients of my shared library?
They will typically go in ${prefix}/include/mylibrary where ${prefix} is the installation root (often /usr for a distro and /usr/local for distribution 3rd party libs).
This way programs include them like:
#include <mylibrary/header.h>
For more information checkout the GNU Coding Standards.
Most Linux based systems are GNU based operating systems and follow GNU standards. But there are differences.
Different distros have different package management systems for installing software but most distros use either one of two (rpm & deb). Many build systems abstract away the precise locations for things like headers and libraries so if you use something like autotools it allows the person doing the install to select the location or use the distro's defaults.
You should be prepared for minor differences between distros so you may have to prepare specific install packages for some things.

compile boost under linux without being root [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
how i can compile boost under linux without write in system folders.
I need to get headers files and shared libraries of boost in one my specific folder.
You don't need to be root to compile Boost on Linux. Moreover, many Boost libraries are header only so no compilation is needed. see also Building and Installing the Library and Easy Build and Install for more details.