ubuntu OS, g++, cannot find -lplplot - c++

Here's the problem:
I'm gonna use some scientific plotting in my C++ programs, and I find PLplot.
Then I just typically do apt-get install cl-plplot and do pkg-config --cflags --libs plplot.
Then, I include the header file #include <plplot.h> in my code, and do g++ -lplplot main.cpp. It just returns "cannot find -lplplot".
However, I tried to locate or find plplot.so and get nothing! It's not in /usr/bin/lib or /usr/lib or anywhere else! I'm confused with that..
Anyone with any general idea about this type of error?

First search for plplot.h in your system. if it exist use -I flag for compile.
for example:
g++ -I /path_to_your_file/ -lplplot main.cpp

Related

Link PCL libraries while compiling C++ programs in Linux

I am new to the Point Cloud Library. There is a thing that has been bugging me for some time.
So, on my system, whenever I have to compile a C++ program, which requires OpenCV libraries to be linked, I use the following terminal command:
g++ -std=c++11 fileName.cpp -o executableFile `pkg-config --cflags --libs opencv`
Now, things have turned to a point where I have to use PCL. But, everywhere (including the PCL's official website) people link PCL libraries using a CMake file, and I am not familiar with CMake.
Is there a way to include the PCL libraries without writing a CMake file and just including some more flags/parameters to the terminal command?
I am using Ubuntu 18.04.
I experimented for a while, and here is how I figured this out.
man pkg-config tells you the folders where pkg-config looks for .pc files. So, I checked those folders for the exact .pc file names that I want pkg-config to link with my .cpp file. I found the required file (pcl_io-1.11.pc) at \usr\local\lib\pkgconfig
Next, I modified my terminal command to the following (please consider two back-quotes as a single back-quote below)
g++ -std=c++14 pcd_write.cpp -o pcd_write ``pkg-config --cflags --libs pcl_io-1.11`` -lboost_system
Note: Not including the -lboost_system would result in another error message. I found this helpful.
This compiled successfully. But, on running the executable, I would get this error message:
./pcd_write:error while loading shared libraries:libpcl_io.so.1.11:cannot open shared object file:No such file or directory
The solution to this problem was found here
sudo /sbin/ldconfig -v
Then, running the executable gave the expected results.

How Do I Get WxWidgets setup.h after I install all the .debs on Debian?

Problem first, then details:
I copied a hello-world program from the wxwidgets tutorials and tried to compile it from the command line like this:
g++ -o h wxhello.cpp -I/usr/include/wx-3.0
The compile terminated quickly because it could not find "wx/setup.h". I researched this apparently EXTREMELY COMMON PROBLEM and learned that there is supposed to be a second include path, pointing to the place where the individual setup.h that suits my situation can be found. So I tried:
find /usr/include/wx-3.0 -name "setup.h"
And the output was nothing.
So I installed wxWidgets by marking libwxgtk3.0-dev in Synaptic and allowing all the dependencies to be installed (something like 40 packages in all because I just set this thing up).
How do I get my program to compile?
You need to have wx-config --cxxflags --libs in your command line enclosed in back-ticks like this
g++ -o h wxhello.cpp `wx-config --cxxflags --libs`
This is not the solution on Windows, but it should work on any Linux.
This is not documented in a searchable fashion as far as I can tell.

Linking the Allegro library to a C++ application using the g++ compiler (Ubuntu)

In trying to get Allegro (A C++ game programming library) to work with a very simple C++ application in Ubuntu 12.04, I am unable to get the program to compile with the allegro header definitions. It returns the error allegro.h - no such file or directory found. I tried running a pkg-config to find the proper linker command, but that didn't help in compilation.
I am almost certain it is installed correctly at this point. I tried using a pkg-config --cflags --libs allegro-5.0 for the include file paths, none of which worked when using in the g++ compile line.
Thanks in advance.
Running a pkg-config --cflags --libs allegro-5.0 told me wrong on the include path. It told me to use -I/usr/local/include and after some digging into that folder, I found that the include path is -I/usr/local/include/allegro5 instead. It is compiling fine now.

Backslash on Include directories with pkg-config on Mac OS Lion

Good evening everybody,
I have virtually no experience with pkg-config but it seems that I will have to use it in working with openssl. Im on a Mac, which might be of some importance.
The problem is:
i compile my testing program with
cc test.cc `pkg-config --libs --cflags openssl` -o test
i have compiled openssl and installed it in ~/openssl afterwards adding ~/openssl/lib/pkgconfig to the PKG_CONFIG_PATH
since I want to use the newest version instead of the preinstalled one, I specify the options with every compilation
the result of running pkg-config --libs or pkg-config --cflags openssl is -L\~/openssl/lib -lssl -lcrypto
This begs the question for me why there is a backsash and whether my compiled version is used or the preinstalled one and if the first one is the case how i could possibly fix this...
Any kind of help is appreciated
The expansion of ~ to your home directory only occurs in certain circumstances. Basically, it's the shell that's doing it. If a program or a file API sees the tilde, it is interpreted as a literal; it's not expanded.
Use $HOME when setting PKG_CONFIG_PATH instead, as in $HOME/openssl.

Problems compiling gtkmm

OS: Fedora 14
Compiler: g++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)
I installed gtkmm24-devel from repository via yum. To make sure the install went as planned I decided to try one of the examples on the page.
#include <gtkmm.h>
int main(int argc, char *argv[]) {
Gtk::Main kit(argc, argv);
Gtk::Window window;
Gtk::Main::run(window);
return 0;
}
I ran the example, and, hey! It said it couldn't find gtkmm.h, no problem, I just forgot to link the library. I added /usr/include/gtkmm-2.4 to my library search through Eclipse. No bueno, g++ still can't find it!
fatal error: gtkmm.h: No such file or directory
I then try to include gtkmm by using #include <gtkmm-2.4/gtkmm.h> and recompile, another error! :(
/usr/include/gtkmm-2.4/gtkmm.h:87:20: fatal error: glibmm.h: No such file or directory
Thanks for reading.
Short answer
Use the output of 'pkg-config gtkmm-2.4 --cflags' for include paths and 'pkg-config gtkmm-2.4 --libs' for libraries to link.
Long answer
It said it couldn't find gtkmm.h, no problem, I just forgot to link the library.
Building a C/C++ program is done in two separate steps. First the source files are compiled, outputting object files; and then the object files are linked together. The error you are getting comes from the compiling step.
On Linux, most libraries come with pkgconfig files to make it easier for other programs to use the libraries. gtkmm also comes with its own pkgconfig files.
You are trying to manually specify /usr/include/gtkmm-2.4 for include path; this is wrong. Instead, use the output of pkgconfig to figure out where the header files are located. To get all the include directories needed for gtkmm, use the following command:
pkg-config gtkmm-2.4 --cflags
For linking, use the following pkgconfig command to get the libraries you need to link with:
pkg-config gtkmm-2.4 --libs
You can test it on the command line by invoking g++ directly.
g++ myfirstprogram.cpp -o myfirstprogram `pkg-config gtkmm-2.4 --cflags --libs`
For more information, see the gtkmm docs: http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-basics-simple-example.html.en
These steps usually help resolving this problem:
Search your computer for glibmm.h
If found - add its directory to the include path list
If not found - Google for glibmm.h and find out which library it is contained in. You will find out in this case it's (surprise!) glibmm. Install it using your package manager.
The problem, as noted in comments, is a compiler error and the compiler is arguing about a missing (header) file. The steps I described above either find the location of the missing file or help you to install a library that the header file belongs to.