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 7 years ago.
Improve this question
This is a newb question. I'm not sure if "external libraries" is the right terminology, but I see some programs include or use libraries or modules that are not programmer-defined. Do I need to do anything special when compiling - do I need to tell the compiler where to find these external libraries?
For example, on this page http://www.unidata.ucar.edu/software/netcdf/examples/programs/, SimpleXyWr.cpp and simple_xy_wr.f90 both reference the netCDF library/module. How does the compiler know where to find the library/module? Do I need to provide the path myself at some point in the compilation?
Typically for GNU compilers -L options tells where to find library and -l tells what library to link. For example,
f77 -o run main.f -L/usr/local/lib -llapack -lblas
will look for libraries in /usr/local/lib driectory and link with lapack and blas libraries
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I'm writing a plugin based emulation system. The way this works is that the main system sets up an ImGui instance and the plugins use ImGui to draw windows to the screen. I'm using a static build of ImGui which is embedded in the host program and linked to at run time; on Linux, this works fine, because the plugin .so files don't need to link against ImGui at compile time, only at run time. On OS X I get errors about "Undefined symbols for architecture x86_64" when trying to link the .dylibs.
Is there a way to tell OS X to leave the linking for run-time also?
Found the answer elsewhere - I need to add the -undefined dynamic_lookup flag on OS X.
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.
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 6 years ago.
Improve this question
I am trying to link libpcap to my project, but I achive an error
skipping incompatible /usr/lib/i386-linux-gnu/libpcap.so when searching for -lpcap
I'm using cross compiler arm linux gcc.
I've found some topics with related problems but i haven't found solution for me.
How to link this lib correctly?
You need to provide libpcap.so built for arm..
You can check for architecture by calling:
file libpcap.so
Output:
/usr/lib/x86_64-linux-gnu/libpcap.so.1.5.3: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=916b377cfe593106dc0b054d63bc4ed0af4ad269, stripped
You can crosscompile the pcap lib from here
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 6 years ago.
Improve this question
How do I import libraries that I can include with #include <> in C++. Specifically, I am trying to import the SDL library, I am using Atom, and my operating system is ubuntu 16.04.
There is default path where compiler searches libraries.
What are the GCC default include directories?
If you are using gcc/g++:
gcc -xc++ -E -v -
Or you have to specify path to the library:
#include "../folder1/header1.h"
#include "../folder2/header2.h"
As already mentioned, you should have this library on your local system.
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.