C++ Not Finding Installed Library - c++

I am desperately trying to install WebKitGTK+, but I have hit a two-hour impasse.
For one, the tarball provided on the website does not seem to follow any of the typical "build from source" conventions, and there are no instructions anywhere. Any build-from-source instructions they provide involve the unstable repository version, which I do not want to use...and anyhow, those do not seem to work.
I can find both the Webkit (libwebkitgtk-3.0-dev) and Webkit2 (libwebkit2gtk-3.0-dev) versions on the repository (I love Synaptic Package Manager), but though I've installed them, C++ (CodeBlocks) fails on...
#include <webkit/webkit.h>
It is worth noting that one of my employees installed the same package (libwebkitgtk-3.0-dev) successfully from the Debian Wheezy repositories, and he can use them in his code just fine, with the same import statement.
I added the path to /usr/include/webkitgtk-3.0/webkit under Global Compiler Settings --> Search Directories --> Compiler. My employee and I both have the exact same paths to this library added - his work, mine don't.
I'm losing my mind now. Help?

In Codeblocks go to the Project Build Options settings. You can get there by right clicking on the project in the "Projects Management" panel on the left side of the screen and choosing 'Build Options' then clicking on the project itself(NOT just the debug/release options) in the window that shows up. Click the "Search Directories" tab and in the compiler subtab you will need to enter the following path:
/usr/include/webkitgtk-3.0/
When adding them make sure you DO NOT add it as a relative path. Additionally in the "Compiler Settings" -> "Other Options" tab you might need to add one or more of:
`pkg-config --cflags gtk+-3.0 `
`pkg-config --cflags glib-2.0 `
`pkg-config --cflags pango `
`pkg-config --cflags cairo `
`pkg-config --cflags gdk-pixbuf-2.0 `
`pkg-config --cflags atk `
`pkg-config --cflags libsoup-2.4 `
On my system I could not get pkg-config to work for webkitgtk itself.

Related

gtkmm: Simple example fails to compile: gtkmm.h: No such file or directory

I am working through the gtkmm documentation. I have started by trying to compile the "Simple Example". Here is the code. It can also be found here.
/// SimpleExample.cpp
#include <gtkmm.h>
int main(int argc, char *argv[])
{
auto app =
Gtk::Application::create(argc, argv,
"org.gtkmm.examples.base");
Gtk::Window window;
window.set_default_size(200, 200);
return app->run(window);
}
I have tried to compile this using
g++ SimpleExample.cpp -o SimpleExample `pkg-config gtkmm-3.0 --cflags --libs`
which should work according to the documentation. (See end of linked page.)
Running pkg-config gtkmm-3.0 --cflags --libs produces
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
I am running Debian 9 Stretch. I installed gtkmm with
sudo apt update && sudo apt install libgtkmm-3.0-dev
Running find /usr -name "gtkmm" produces
/usr/lib/x86_64-linux-gnu/pkgconfig/gtkmm-3.0.pc
/usr/lib/x86_64-linux-gnu/gtkmm-3.0
/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include/gtkmmconfig.h
/usr/include/gtkmm-3.0
/usr/include/gtkmm-3.0/gtkmm
/usr/include/gtkmm-3.0/gtkmm.h
So why does the example not compile?
Updates:
New terminal
pkg-config gtkmm-3.0 --cflags --libs
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
Try
find /usr -name "*gtkmm-3.0*"
/usr/lib/x86_64-linux-gnu/pkgconfig/gtkmm-3.0.pc
/usr/lib/x86_64-linux-gnu/libgtkmm-3.0.so.1.1.0
/usr/lib/x86_64-linux-gnu/libgtkmm-3.0.so.1
/usr/lib/x86_64-linux-gnu/gtkmm-3.0
/usr/lib/x86_64-linux-gnu/libgtkmm-3.0.so
/usr/share/doc/libgtkmm-3.0-1v5
/usr/share/doc/libgtkmm-3.0-dev
/usr/include/gtkmm-3.0
Export location
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig"
Re-run
pkg-config gtkmm-3.0 --cflags --libs
Package xproto was not found in the pkg-config search path.
Perhaps you should add the directory containing `xproto.pc'
to the PKG_CONFIG_PATH environment variable
Package 'xproto', required by 'xau', not found
(That's a different error this time.)
Try to find again
find /usr -name "*xproto*"
/usr/share/pkgconfig/xproto.pc
/usr/include/xcb/xproto.h
/usr/include/GL/glxproto.h
/usr/include/X11/extensions/lbxproto.h
Change export command
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig;/usr/share/pkgconfig"
Re-run, back to square 1
pkg-config gtkmm-3.0 --cflags --libs
Package gtkmm-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtkmm-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtkmm-3.0' found
Problem resolved (sort ot)
I have discovered from reading this question that the path should be colon seperated.
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig"
However this does not solve the problem of why this variable needs to be set at all. pkg-config is used because it is supposed to make compilation simpler, however this isn't any more simple than specifying the include paths manually, as multiple environment variables need to be set.
In addition, the lack of information about this issue online makes me suspect that this is an issue which most users do not encounter, and therefore is probably specific to Debian 9. (I would like to know if anyone else has encounted this problem, and on what OS.)
At first, it is normal that installing gtkmm is a bit complicated. As far as i can see, here in the Stackoverflow forum many users have problem with doing so. Even users in the Windows operating system are confronted with error messages, if they are trying to use gtkmm together with Visual Studio for developing a platform independent app ... But to your question. There are many options what can go wrong. A simple explanation would be, that the debian package “libgtk-3-dev” has to be installed, which is used for creating GTK+ apps in C, because gtkmm uses this package. So the first step is to try out, it the compilation of a C sourcecode for GTK+ works. A second explanation is, that the debian “package manager” is in general broken so switching the Linux distribution would be a good advice. For example, in Fedora a simple dnf install gtk3 gtk3-devel gtkmm30 gtkmm30-devel is enough for starting programming.

Cross-Compiling wxWidgets code from Linux to Windows

I use Code::Blocks IDE with wxWidgets in Debian 8.9 Jessie (x86-64).
When I use the GNU GCC Compiler everything works fine thus compiling nice wxWidgets executable for Linux.
But I need to have my program working on Windows platforms so I have to do cross-compiling.
I have installed mingw32 and followed the cross-compiling instructions given
here.
I did my wxWidgets build configuration as follows:
./configure prefix=/usr/i686-w64-mingw32 --host=i686-w64-mingw32 --enable-unicode --build=`./config.guess` --disable-shared
This is so because the MinGW compiler I have is i686-w64-mingw32, located in the folder /usr/i686-w64-mingw32, and wxWidgets version is 3.1.
My compiler set-up in Code::Blocks should be correct because I managed to do cross-compiling for simple console applications and those run properly on Windows 10.0. But when it comes to wxWidgets applications there are several problems:
The compiler gives me the error (it happens when --static is added to Other compiler options in the build options for the project):
fatal error: wx/app.h: No such file or directory|
Now since wx directory in question is in the path /usr/i686-w64-mingw32/include/wx-3.1 I added this path to the search directories for the project (the build target only for the moment). This worked fine to proceed further.
My compiler settings are: wx-config --host=i686-w64-mingw32 --static --cflags
The compiler swears again (not surprised though :-)):
fatal error: wx/setup.h: No such file or directory|
Ok I've found this one in /usr/i686-w64-mingw32/lib/wx/include/i686-w64-mingw32-msw-unicode-static-3.1, so added this path to the compiler search directories.
The linker is swearing this time (creeping on my nerves):
for the build target:
undefined reference to `wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int)'|
for the release target:
undefined reference to `wxAppConsoleBase::CheckBuildOptions(char const*, char const*)'|
My linker settings are wx-config --host=i686-w64-mingw32 --static --libs
I tried hard to fix this with several different build options for the wxWidgets library but with no effect on the result. So please, someone help!
I also noticed that running ./config.guess form the wxWidgets download directory gives me x86_64-unknown-linux-gnu. Thus this mean I should use x86_64-w64-mingw32 (I have this one installed in /usr/x86_64-w64-mingw32) compiler instead i686-w64-mingw32?
So the main issue is that the command wx-config --static --cflags is not recognized in Other compiler options and wx-config --static --libs is not recognized in Other linker options.
The problem persisted even though I added the path to wx-config file in the .bashrc file from the home directory, i.e. export PATH="$PATH:/usr/i686-w64-mingw32/bin". At that time I was able to run wx-config from the terminal at any location.
To solve it I've changed the options to /usr/i686-w64-mingw32/bin/wx-config --static --cflags in Other compiler options and /usr/i686-w64-mingw32/bin/wx-config --static --libs in Other linker options. This worked as a charm.
I've added the location of libstdc++-6.dll (simply found it with a search in the file manager) in Link libraries and the flags -static and -static-libgcc in Other linker options and finally did the testing with the minimal sample as Igor suggested. Just create new console application, add minimal.cpp file to it and all of the mentioned above.
The compiler did a Minimal.exe file that I have opened successfully with wine.
Note: All the include directories I mentioned in my question were in wx-config --cflags for the compiler and wx-config --libs for the linker, so no need to add them in search directories.

Using CodeLite IDE for OpenCV in Ubuntu 16.04 LTS

I can compile a sample C++ Code (including OpenCV) using both CMake and following command line:
g++ cv.cpp -o cvapp pkg-config --cflags --libs opencv
But I want to use CodeLite IDE for this purpose. I have added
/usr/include/opencv;/usr/include/opencv2
in the Include Paths under compiler tab in project settings. And added
/usr/local/lib
in Libraries Search Path under Linker tab.
But still, I am getting errors shown in this screenshot for a sample code.
Now is it possible to use CodeLite for OpenCV coding environment? If yes then how?
To use opencv in codelite the simplest option is to continue using pkg-config, you can do this as follows:
Right click on the project name and select settings...
2.Open the following dialog and select the Linker tab, in that window add pkg-config --cflags --libs opencv in linker-options:
Press the apply button and Ok and then compile the project.

Code Building Error in Eclipse CDT for Player/Stage simulator

I am using Player/Stage for my thesis work. But, I am getting undefined reference error messages while I want to build this code in Eclipse CDT-
#include <iostream>
#include <playerc++.h>
#include <playerclient.h>
#include <clientproxy.h>
using namespace std;
int main()
{
PlayerClient robot("localhost",6665);
return 0;
}
The error message is:
08:40:02 **** Build of configuration Debug for project firstTest ****
make all
Building file: ../src/firstTest.cpp
Invoking: GCC C++ Compiler
g++ -I/usr/local/include/player-3.0/libplayerc++ -include/usr/local/include/player-3.0/libplayerc++/playerc++.h -include/usr/local/include/player-3.0/libplayerc++/clientproxy.h -include/usr/local/include/player-3.0/libplayerc++/playerc++config.h -include/usr/local/include/player-3.0/libplayerc++/playerclient.h -include/usr/local/include/player-3.0/libplayerc++/playererror.h -include/usr/local/include/player-3.0/libplayerc++/utility.h -O0 -g3 -Wall -c -fmessage-length=0 `pkg-config --cflags playerc++` -MMD -MP -MF"src/firstTest.d" -MT"src/firstTest.d" -o "src/firstTest.o" "../src/firstTest.cpp"
Finished building: ../src/firstTest.cpp
Building target: firstTest
Invoking: GCC C++ Linker
g++ `pkg-config --libs playerc++` -o "firstTest" ./src/firstTest.o
./src/firstTest.o: In function `main':
/home/nafees/workspace/firstTest/Debug/../src/firstTest.cpp:19: undefined reference to `PlayerCc::PlayerClient::PlayerClient(std::string, unsigned int, int)'
/home/nafees/workspace/firstTest/Debug/../src/firstTest.cpp:19: undefined reference to `PlayerCc::PlayerClient::~PlayerClient()'
collect2: error: ld returned 1 exit status
make: *** [firstTest] Error 1
08:40:02 Build Finished (took 514ms)
I have followed this nice tutorial posted by Jenny- http://yorkroboticist.blogspot.com/2010/03/playerstage-on-eclipse.html
In this link you will get the snapshots of my Eclipse Project Properties:
https://www.dropbox.com/sh/9hcmditufu0lt6v/AAChqD1-FMM9FhvTWpuOGMQ-a?dl=0
I have tried a lot of ways to remove this error. but, all in vein. Please help me to continue my thesis.
With thanks
Nafees
I have figured out the "undefined reference" problem.....
If anyone wants to use eclipse CDT for stage/player simulation, please follow these steps. I am assuming that you have installed the Player/Stage properly.
Go to Project Properties.
Expand C/C++ Build.
Click on Settings.
If you want to build C++ code, follow these steps-
Under GCC C++ Compiler, click on Miscellaneous tab.
There is a box named "Other flags". Paste this line(with ` symbols) on the box-
`pkg-config --cflags playerc++`
caution: Never edit the existing lines in the box. Just paste the above line beside the existing line with an space. And keep in mind ' and ` is not same.
Then, go to includes/directories(name may vary according to eclipse version) tab. There is an "include paths(-I)" box. click on add button and navigate to- Computer > usr > local > include > Player- x.x and press ok.
If you want to build C code, Skip number 4 instruction and follow these steps instead-
Under GCC C Compiler, click on Miscellaneous.
There is a box named "Other flags". Paste this line (with ` symbol) on the box-
`pkg-config --cflags playerc`
caution: Never edit the existing lines in the box. Just paste the above line beside the existing one it with an space. And keep in mind ' and ` is not same
Go to includes/directories(names may vary according to eclipse version) tab. There is an "include paths(-I)" box. click on add button and navigate to- Computer > usr > local > include > Player- x.x and press ok.
Now, The most important steps come here. Under GCC C++ Linker, click on Miscellaneous tab. There is a box named "Linker flags".
if you are using C++, paste the following line-
`pkg-config --libs playerc++`
If you are using C, paste the following line instead of the above-
`pkg-config --libs playerc`
Now, go to Libraries tab and there you will see "Libraries (-l)" box. Press add button and
If you are using C++, paste the line-
playerc++
If you are using C, paste the following line instead of the above-
playerc
Finally, there is a box named "Library search path (-L)" beneath. Click on add button and navigate to- Computer > usr > local > lib and click ok.
Thats it....... Now try to compile and build an example code. :) :) :)

eclipse cdt: add include path from pkg-config

i want to add a dynamic configuration path (generated from pkg-config) to my project. (this is basically for third-party dependencies like boost, so workspace includes is not appropiate, and filesystem include neither because that would be hardcoded and every developer would have to change that manually)
i am on project properties->c++ general->paths and symbols->includes tab->add...->add directory path->variables but i can only select among existing variables, how do i create a new variable dynamically generated from a command line program? like pkg-config --cflags boost-1.43?
this is easy to do in netbeans; you just add the pkg-config commandline with the backquotes in the build additional options and it resolves the build include and even in theory it should update the indexer (although truth be said, last time the indexer was correctly updating from pkg-config was on netbeans 6.8, it has been broken on 6.9 and 6.9.1)
i read this StackOverflow post but i still not sure how it helps this specific case
i read somewhere that you can use $(shell pkg-config...) to generate environment variables but not sure where to place the command
if there is no easy out of the box solution i'll try the script in this blog post
btw, i'm using eclipse helios -cdt 7
thanks!
Pkg-config support is finally coming to CDT and will be finished on August.
http://code.google.com/p/pkg-config-support-for-eclipse-cdt/
you can use $(shell pkg-config --cflags your_libs) in:
Project properties->C/C++ Build->Settings->"Tools Settings" tab->**C Compiler**->Miscellaneous->Other Flags
and
you can use
$(shell pkg-config **--libs** your_libs)
in
Project properties->C/C++ Build->Settings->"Tools Settings" tab->**C Linker**->Miscellaneous->Other Flags
if the linker doesn't link, make sure (for example in the build console window) that the pkg-config flags appear after the objects to link.
you can do this in properties->C/C++ Build->Settings->"Tools Settings" tab->C Linker->Command line pattern moving ${FLAGS} to the end :
from this (for example) :
${COMMAND} **${FLAGS}** ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} **${INPUTS}**
to this :
${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} **${INPUTS} ${FLAGS}**
In eclipse 4.3.2 at least, it looks as though it's possible to simply add
`pkg-config --libs <mylibname>`
in
Project->Properties->C/C++ Build->Settings->GCC {C|C++} Linker->Miscellaneous->Linker Flags
similarly
`pkg-config --cflags <mylibname>`
in
Project->Properties->C/C++ Build->Settings->GCC {C|C++} Compiler->Miscellaneous->Other Flags
what i found so far is that you can do
project-> properties-> c++ build-> build variables
add a new variable of string type.
Call it whatever you like:
UNITTEST_CPP_CXXFLAGS
then set as its value:
$(shell pkg-config --cflags unittest-cpp)
the go to project properties-> c++ general -> path and symbols,
includes.
Select languages c++, otherwise it defaults to assembly source file.
Click add.
On the add directory path, click variables... (because we want to add the variable we have just created)
type the name of the variable (UNITTEST_CPP_CXXFLAGS), press enter and ok
when you rebuild the result of the shell command is replaced in a -I option (for the gnu gcc toolchain at least), in general pkg-config output might include one or more -I so this won't work. Lets go to c++ build->settings->tool settings->gcc c++ compiler->miscellaneous. In there, add ${UNITTEST_CPP_CXXFLAGS} to the other flags.
now the include will be added, but there is no hope of getting the indexer to browse those include!
Use this link at eclipse help/install new spftware. It installs pkg-config. https://raw.githubusercontent.com/TuononenP/pkg-config.p2/master/site.xml
I did find this link in this webpage. https://groups.google.com/forum/#!topic/pkg-config-support-for-eclipse-cdt/HNblZRTKBQQ