I'm trying to install libwebsockets C library with vcpkg according to the instruction. And don't understand something.
OS - Ubuntu 20.04
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg install [library-name]
Library is installed and what to do next? How to compile test files with the library?
The question is more about how to use vcpkg on linux.
You can give an example of another library installed with vcpkg.
vcpkg is a C/C++ package manager, it is very necessary in windows.
However, in ubuntu, itself provides a very complete package management mechanism.
Therefore, even if you are building a cross platform software system, do not use vcpkg in ubuntu :)
You can try this:
$> sudo apt install libwebsockets-dev
In this way, the libwebsockets header files and library files you need have been installed and can be used directly.
Here is another example:
I want to install gtkmm4 in ubuntu 20.04 LTS, since gtkmm4 is not available for apt download I'm installing it with vcpkg.
for simplification, I'm setting VCPKG_DIR to the vcpkg directory I cloned.
export VCPKG_DIR=/path/to/vckpg
Then for a C++ program, you can write CMake file like below
PROJECT(gtkmmtest)
cmake_minimum_required(VERSION 3.10)
set(VCPKG_DIR $ENV{VCPKG_DIR})
include(${VCPKG_DIR}/scripts/buildsystems/vcpkg.cmake) # --> important
# Use the package PkgConfig to detect GTK+ headers/library files
FIND_PACKAGE(PkgConfig REQUIRED)
FIND_PACKAGE(Threads REQUIRED)
pkg_check_modules(GTK4 REQUIRED gtk4)
PKG_CHECK_MODULES(GTKMM gtkmm-4.0)
include_directories(${GTK4_INCLUDE_DIRS})
include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${VCPKG_DIR}/packages/gtk_x64-linux/lib)
link_directories(${GTK4_LIBRARY_DIRS})
add_definitions(${GTK4_CFLAGS_OTHER})
target_link_libraries(${GTKMMTEST} PRIVATE ${GTK4_LIBRARIES} ${GTKMM_LIBRARIES} pthread)
Complete CMake file can be found here
You can still use the the standard include_directories and link_directories if there is no PkgConfig avilable.
eg:
include_directories(${VCPKG_DIR}/packages/gtkmm_x64-linux/include/gtkmm-4.0/)
Library is installed and what to do next? How to compile test files with the library?
The question is more about how to use vcpkg on linux.
The answer to this question really depends on your buildsystem and the port/library you want to use and not the platform itself.
In the case of libwebsockets libwebsockets-config.cmake get installed so you could use CMake and do a find_package(libwebsockets CONFIG REQUIRED) to get the imported targets the port exports within LibwebsocketsTargets.cmake. Of course this requires setting CMAKE_TOOLCHAIN_FILE to the vcpkg toolchain (<vcpkg_root>/scripts/buildsystems/vcpkg.cmake) or including it before the first project() in your CMakeLists.txt (more details are mentioned in the vcpkg docs which you hopefully read....)
Other libraries/ports might export *.pc files. For these FindPkgConfig.cmake can be used directly (see CMake docs) or you can setup PKG_CONFIG_PATH and prepend <vcpkg_root>/installed/<triplet (here probably: x64-linux)>/(debug/)lib/pkgconfig for other buildsystems like autotools or manual makefiles etc.
In the end how to use vcpkg or more precisly the libraries from it depends on what buildsystem you intend to use.
Related
I am building a web server using the libwebsockets library on a TS-7800 board using the arm-linux-gcc cross compiler. Using Ubuntu. Installed CMake, OpenSSL, and libwebsockets and built the library per the instructions on Github.
I made a "hello world" C file which #includes libwebsockets.h
When I compile the executable with gcc, it compiles fine and the .exe runs.
When I compile with arm-linux-gcc, I get the following:
root#gordon-MS-7A39:/# arm-linux-gcc -o hellosockets /home/gordon/workspace/HelloCrossWorld/hello_cross.c
/home/gordon/workspace/HelloCrossWorld/hello_cross.c:3:27: libwebsockets.h: No such file or directory
It appears that arm-linux-gcc compiler cannot "see" the header file for libwebsockets. I'm guessing that the installation of the websockets library was successful because gcc can see it.
How do I enable the arm cross compiler to see the libwebsockets.h file?
Thank you for your input!
You'll need to add armhf architecture to your package management system. Perform the following actions as super user:
dpkg --add-architecture armhf
apt update
apt install libwebsockets-dev:armhf
Make sure you're also using the armhf toolchain:
apt install binutils-arm-linux-gnueabihf g++-arm-linux-gnueabihf
Alternatively, take a look at Buildroot
I was unaware of the -I and -L preprocessor options for gcc and arm-linux-gcc.
I was able to add libraries to the project and will look into creating makefiles for the project.
I have a git repository which I can build with:
./autogen.sh
./configure
make
sudo make install
Now I want to cross compile it for windows with the mingw32/mingw-w64 cross compiler.
I tried it with
export CXX=/usr/bin/x86_64-w64-mingw32-gcc
but that didn't work for me.
I have configure eclipse that I can compile windows executables as well, that works, but only with plane c code. Now I need external libraries, which I have to compile for windows as well.
As described on a(n old, but mostly correct) page of the MinGW-w64 wiki (written by yours truly a long time ago):
./configure --host=x86_64-w64-mingw32
should do the trick if the package doesn't need special handling for Windows.
I use Tcl_CreateObjCommand to build a Tcl extension in C called libA.so, the C code call the function from an external C library called libext.so, where should I put libext.so, so that the tcl could find and load it when it load libA.so
Use a package installer
If you have a package manager you should install tcl/tk with it.
sudo apt-get install tk
or you might want also tk-dev (which is sometimes called tk-devel):
sudo apt-get install tk tk-dev
Install manually
You can put so's manually in /usr/local (libraraies in /usr/local/lib/ and include files in /usr/local/include/), But remember to avoid installing them under /usr if you do have a packaging system.
There's also an option of putting them under your project directory, but you'll have to help the dynamic linker find them (using LD_LIBRARY_PATH or ld.so.conf). Also, you'll have to update your project's include paths and library paths.
I want to build some package from source (e2fsprogs to be more concrete) and install its header files to my system. After that I will delete the build tree so it will not be accessible anymore. What is the right way to do this?
When I want to install program, I make simply:
$ ./configure
$ make
# make install
What are the equivalent actions when I want to install headers?
For e2fsprogs, quoting verbatim from the INSTALL file shipped with the sources:
7) Install the include files and libraries
You can run `make install-libs' to install the include files and
libraries. Please note that this installation is not needed for the
programs to work. It is only needed if you expect to develop other
programs using the libraries or if you want to compile other program
using these libraries (like the 4.4BSD dump and restore port).
More generally though, when I want to find out what is the 'proper' way to install something that has worked for others, I look at:
What the package looks like, in my favourite distro
How the package is built for my favourite distro
I am writing C program on Windows with MingW and want to use EXPAT XML library. I want to compile my program statically, so I need static .a library.
Is there any way to compile EXPAT to .a static, independent library on Windows?
If you download official releases from Expat Sourceforge project page you won't be able to compile and install the library with MSYS nor MinGW. You will need an installation of CygWin to configure, make and install.
To compile and install native MinGW library you need modified version of configure script and libtool. Just download expat source tarball provided by MinGW instead of main original expat. Also you may want use precompiled binaries instead
I just downloaded and built the package, it appears to have made a static library by default. What's not working for you?
You can get dynamic and static version of expat using MinGW package installer:
open a cmd or shell
update the package list: mingw-get update (optional)
install the package(s) you need:
dynamic (.dll): mingw-get install expat
static (.a and .dll.a): mingw-get install libexpat
depending on what you've chosen, you'll find ...
dynamic lib in <your mingw>/bin, file: libexpat-1.dll
static lib in <your mingw>/lib, files: libexpat.a, libexpat.dll.a, libexpat.la
Package overview:
package expat: Dynamic libexpat-1.dll incl. xmlwf.exe
package libexpat: Static libexpat.a, libexpat.dll.a and libexpat.la