How to add library to PKG-CONFIG Mac - c

I am trying to get flikcurl to sync with pkg-config. I tried installing it via macports, but it results in an error during build.
I am able to find the flickurl.a static library and the src headers.
My question is, how do I add these to the PKG_CONFIG path?
Thanks!

If flickcurl.pc is in the directory /p/a/t/h, you need to add /p/a/t/h to PKG_CONFIG_PATH, which is a colon separated list of all the places that pkg-config will look for pc files:
$ export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}${PKG_CONFIG_PATH:+:}/p/a/t/h

Related

how to add directory to search path in msys2?

I am trying to install GTK 3 for C using this tutorial
after following the full install instructions and trying to build a simple program using this I was met with
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk+-3.0', required by 'virtual:world', not found
error. So I re did all the steps and noticed
Plus after installing the toolchain base-devel for C,C++ I checked if the old problem stayed using pkg-config --modversion gtk+3.0 I found this command here
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk+-3.0', required by 'virtual:world', not found
same issue. So my question is, Is there a way to add C:/msys64/mingw64/share/ to search path?
Use this command:
$ export PATH=$PATH:/c/msys64/mingw64/share

Creating CMake project for libwebsocket

The title states the problem statement: I'm trying to create a CMake project utilizing the libwebsocket library, but I can't find any information for doing so.
Is there anyone who have tried this? A simple CMakeLists.txt for e.g. the test-server program would be much appreciated!
I've compiled and installed the library on my Ubuntu 14.04 machine.
EDIT: I would also like to know if anyone has experience in using the libwebsocket lib w/ C++?
EDIT 2:
After using #evadeflow's answer I'm able to run cmake and build the project. However now I get the following runtime error:
And here's an ls of the /usr/local/lib/ folder
It seems like the libwebsockets.so.7 file is not found?
From CMake:
${LIB_WEBSOCKETS_INCLUDE_DIRS} = /usr/local/lib
${LIB_WEBSOCKETS_INSTALL_DIR} = /usr/local
EDIT 3:
Solved edit 2 by:
Editing the file /etc/ld.so.conf and add /usr/local/lib.
Reference: https://lonesysadmin.net/2013/02/22/error-while-loading-shared-libraries-cannot-open-shared-object-file/
If you've already installed libwebsockets, something like this ought to work:
cmake_minimum_required(VERSION 2.8)
find_package(PkgConfig)
pkg_check_modules(LIB_WEBSOCKETS REQUIRED libwebsockets)
get_filename_component(
LIB_WEBSOCKETS_INSTALL_DIR
${LIB_WEBSOCKETS_LIBRARY_DIRS}
DIRECTORY
)
add_executable(
test-server
test-server/test-server.c
test-server/test-server-http.c
test-server/test-server-dumb-increment.c
test-server/test-server-mirror.c
test-server/test-server-status.c
test-server/test-server-echogen.c
)
target_link_libraries(
test-server
${LIB_WEBSOCKETS_LIBRARIES}
)
set_target_properties(
test-server
PROPERTIES
INCLUDE_DIRECTORIES
${LIB_WEBSOCKETS_INCLUDE_DIRS}
LINK_FLAGS
"-L${LIB_WEBSOCKETS_LIBRARY_DIRS}"
COMPILE_DEFINITIONS
INSTALL_DATADIR="${LIB_WEBSOCKETS_INSTALL_DIR}/share"
)
This is basically a stripped-down version of what's in the CMakeLists.txt file from the libwebsockets github project, without all the platform- and build-specific conditionals.
I hope this is enough to satisfy your request for a 'simple' CMakeLists.txt example. I tested it with CMake version 2.8.12.2; it should work fine as-is if you've installed libwebsockets to its default prefix of /usr/local; however, if you installed to a different location, you will need to set PKG_CONFIG_PATH in the environment from which you invoke cmake.
Also, as explained in the CMake documentation, you will need to replace DIRECTORY with PATH in the get_filename_component() invocation if you're using CMake 2.8.11 or earlier.
UPDATE: Regarding the file not found error from your follow-up comment, this is almost certainly due to libwebsocket.so[.7] not being on the linker's default path. There are at least three ways to fix this, but the easiest way to verify that this is the problem would be to just launch the app from the terminal using:
$ LD_LIBRARY_PATH=/usr/local/lib ./test-server
If it works, you know that was the issue. (Oops—I see you've figured it out in the meantime. Yeah, updating /etc/ld.so.conf is another way. Or, you can force CMake to link to the static version of libwebsockets [as described in this answer] is another. But I like your solution best.)
UPDATE: One thing that wasn't mentioned about /etc/ld.so.conf is that you generally need to run sudo /sbin/ldconfig after editing it in order to update the shared library cache. And—when setting non-default paths for a particular application—many people consider it good form to add a new 'sub-config file' in /etc/ld.so.conf.d rather than edit the global ldconfig file. (For the case of adding /usr/local/lib, though, this is such a common requirement I'd be inclined to dump it in the global config, which is what lots of Linux distros do, anyway.)

Linking SDL2 with gcc

After having downloaded the development library for SDL2 and attempting to link it with the -lSDL2 command in gcc, I am told that the library can not be found. Is there a specific directory i should place the framework in ? Or can I specify the directory in the command line so it knows where to link it from?
You use the -l (lower-case L) to tell the linker to link with a specific library.
You use the -L option to tell the linker about which folders to search for libraries.
So if you have install SDL2 in a non-standard location, use the -L option to specify where the library is installed, just like you use the -I (capital i) to specify where headers are for the preprocessor to find them.
If you have not placed it within one of the standard paths where to search for libraries, you should set and export a correctly defined LD_LIBRARY_PATH/LIBRARY_PATH variable.
This discussion contains enough information.

CMake: how to specify from command line where to look for locally installed libraries

I am building locally a dependencies and installing in a local directory. Now I would like to tell CMake to look into that local directory for include and libraries, in addition to all the standard places.
I tried this:
cmake -D CMAKE_LIBRARY_PATH=`realpath ../target`/lib CMAKE_INCLUDE_PATH=`realpath ../target`/include .
But it did not work. Any idea?
You can use the
find_library()
command to search for libraries.
With
include_directories()
you tell cmake where to look for include files
You can first add the folder to your PC's system environment, e.g. called PersonalLib_DIR that points to the folder. Then you can add it for include and libraries by accessing $ENV{PersonalLib_DIR} via CMake:
For include:
include_directories($ENV{PersonalLib_DIR})
For libraries (assume you want to link the aLib.lib under the folder):
target_link_libraries(youProject $ENV{PersonalLib_DIR}/aLib)

"'portaudio.h' file not found" error in XCode 5.1

I've downloaded the portaudio codebase and compiled it fully with source, and installed it to my system with these commands:
./configure
make
sudo make install
But XCode is complaining to me, even when I put -lportaudio in the Other Linker Flags for the project settings.
I've researched this problem and tried whatever I could find on Stack Overflow, but there was no decisive answer that would work for me. Any advice on how to fix this?
I'm using an older version of XCode and haven't bothered looking at how the interface might have changed in the newer versions, but this is generally solved for me by modifying the User Search Paths under your project settings. Look at the screenshot, add /usr/local/include to Header Search Paths and make Always Search User Paths "Yes." That should do the trick
Edit:
One more thing to note, this is only /usr/local/include because that's the default install directory for the portaudio.h file in the portaudio build (as it is with many libraries).
If you have a different prefix other than /usr/local/include, add that instead.

Resources