I'm running Ubuntu. I followed each and every step in the http://wiki.allegro.cc for installation and set up of Allegro5. If I run my program from the command line, I know I need to use
gcc -Wall main.cpp `pkg-config --cflags --libs allegro-5.0
plus any other packges I use. (I don't know what all of it means, but I know I need it)
What I need help with if figuring out what I need to do in Codeblocks > Settings > Compiler so that it will link to the allegro library so that I don't get a hundred and one undefined reference errors. I don't know what I'm looking for, and I don't know where to look. Help a new guy out.
Thanks.
edit: I know I'd need
allegro-config --libs --static
in the Linker for Allegro 4.2
Where can I look and what do I need for Allegro5?
If Codeblocks doesn't support entering `pkg-config --cflags --libs allegro-5.0` directly, then just open up a terminal and type in (no backticks):
pkg-config --cflags --libs allegro-5.0
Then copy/paste the result of that into the compiler settings inside Codeblocks.
Related
I am compiling a C++ program on Windows. The program uses the SDL2 library. I run the following pkg-config command to obtain the correct flags to pass to the GCC compiler.
$ pkg-config sdl2 --cflags --libs
which gives output
-lpthread -lasound -IC:/sdl2/include/SDL2 -LC:/sdl2/lib -lSDL2
However when using these flags with GCC the program fails to compile, giving the error
cannot find -lasound
Is this a library I need to obtain in order to use SDL2, or am I making a mistake somewhere?
GCC not find this library. Find file libcomdlg32.a and find your -lasound file and copy -lasound file in folder, where's libcomdlg32.a file.
I am a student currently working on a project to implement Intel Hyperscan for Virus Signature Scanning on Ubuntu 16.04.
On the system, I have gcc 5.4.0 and g++ 5.4.0.
Hyperscan uses CMake to "build" itself.
Having successfully build Hyperscan, I can't seem to be able to find a way to compile my own code for it. I also could not find any "proper" way of compiling code meant for Hyperscan online, hence I assumed g++ would be right. I have tried,
g++ -o -std=c++11 test test.cc $(pkg-config --cflags --libs libhs)
only for it to give the error: hs.h: No such file or directory
Hence I used,
g++ -o -std=c++11 test test.cc -I../hyperscan/src $(pkg-config --cflags --libs
libhs)
to get another error:
/usr/bin/ld: cannot find -lhs and collect2: error: ld returned 1 exit status
At this point, I am kind of lost and can't really progress with my project. Am I using g++ wrongly? Have I built Hyperscan incorrectly? Any tips or solutions would be greatly appreciated!
$(pkg-config --cflags --libs libhs) only works when library and related development files are installed on the system. Looks like you have source code of library, so first you need to build and install library itself, only then compile your test program.
Also, library may be available in standard repositories, then you maybe want to install it using something like "sudo apt install libhs-dev", however, if you have source code of particular version that you need to work with, or library is closed source and non-public, then the only way is to compile and install it manually. Refer to documentation, README, INSTALL files that may be supplied with library code and follow build and installation procedures described there.
I wrote a program with openCv libraries and compile it with pkg_config as I mentioned below:
g++ imageproc.cpp -o imageproc pkg-config opencv --cflags --libs
now I must check a flag in my Database for run some functions in my program So I write some query to MySQL server. the problem is that I don't know how I must compile the program. previously I compile programs with query in this way:
gcc funcname.c -o funcname mysql_config --cflags --libs
Can any body help me to compile this program (which has opencv codes and query command)?
Thanks in Advnce.
I want to call gtk+ routines from a C++ program test.cpp, and he encountered a problem while building my program.
I am getting the following error:
g++ test.cpp -o test.x
test.cpp:1:22: fatal error: gtk/gtk.h: No such file or directory
# include <gtk/gtk.h>
Somehow I need to link to gtk+. What will be the correct compiler declarations get my program working.
To compile a program using gtkmm, you need to use the following command:
g++ program.cc -o program `pkg-config --cflags --libs gtkmm-3.0`
The pkg-config --cflags --libs gtkmm-3.0 part provides the include paths and the linker options.
Source: The Flaming Manual, which you should Read.
I'm not sure about gtk in particular but this is a simple file not found issue.
You need to be sure that your system includes search path contains a folder gtk in it which in turn has a file called gtk.h.
Please read about the GCC search paths.
This is also likely a duplicated question so it will probably be closed off soon by the community.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
OpenCV on ubuntu 11.10
I am having a very hard time trying to install OpenCV on Ubuntu. I believe that I have already installed OpenCV; however, I am trying to compile one of the samples program kalman.cpp with Eclipse, and I am not able to compile it. My problem I believe is linking with the libraries.
I have seen a lot of tutorial, and I do not understand why after installing opencv in my computer, I get the following output after using the command pkg-confi opencv --libs:
manuel#manuel:~$ sudo pkg-config opencv --libs
/usr/local/lib/libopencv_calib3d.so
/usr/local/lib/libopencv_contrib.so /usr/local/lib/libopencv_core.so
/usr/local/lib/libopencv_features2d.so
/usr/local/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so
/usr/local/lib/libopencv_highgui.so
/usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so
/usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so
/usr/local/lib/libopencv_objdetect.so
/usr/local/lib/libopencv_photo.so
/usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_ts.so
/usr/local/lib/libopencv_video.so
/usr/local/lib/libopencv_videostab.so
Every tutorial out there the libraries appear as:
-L/where/you/have/installed/opencv/lib -lcxcore -lcv -lhighgui -lcvaux
This is really annoying because Eclipse cannot find the library as libopencv_contrib.so. It is waiting for something as -lopencv_contrib
I really appreciate the help. Please let me know what I am doing wrong.
I have never used OpenCV with Eclipse. I basically compile it using gcc or g++ (depending on c or C++) file.
for C file,
$ gcc -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.c .c` opencvtest.c `pkg-config --libs opencv`
for C++ file,
$ g++ -ggdb `pkg-config --cflags opencv` -o `basename opencvtest.cpp .cpp` opencvtest.cpp `pkg-config --libs opencv`
For more information, see http://jayrambhia.wordpress.com/2012/05/08/beginning-opencv/
If you are comfortable with this, I don't think you would need to use Eclipse.
Hope this helps.
To link to a library you need to specify the path to the directory where it is located using the -L /path/to/libraries flag.
You also need the specific libraries you want using -l my_library.
Usually you also need to specify the necessary include paths using -I /path/to/headers
pkg-config can be used as a helper to do this, as it returns the exact parameters you need in order to use a library.
You should rather use it like this:
echo `pkg-config opencv --cflags --libs`
resp.
g++ my_first_opencv_app.cc `pkg-config opencv --cflags --libs`
which on my system evaluates to
g++ my_first_opencv_app.cc -I/usr/include/opencv -lml -lcvaux -lhighgui -lcv -lcxcore
To get it to work with eclipse, you probably need to specify the include path (/usr/local/include/opencv ?), the library path (/usr/local/lib ?) and the libraries you need via some GUI element somewhere in the project settings. You probably shouldn't need pkgconfig then.