The goal: make Rabbitmq-c dynamically linked via gcc (https://github.com/alanxz/rabbitmq-c).
Project is called storeman:
#include <stdarg.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <amqp_tcp_socket.h>
#include <amqp.h>
#include <amqp_framing.h>
#include <assert.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
int main(int argc, char const *const *argv)
{
amqp_connection_state_t conn;
conn=amqp_new_connection();
exit(0); //Everything else is deleted for testing
}
1. Download, compile and install library.
In new build folder inside rabbitmq-c download path:
cmake ..
cmake --build .
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
make
make install
Finally it does the following succesfull output:
[ 15%] Built target rabbitmq
...
[100%] Built target test_tables
Install the project...
-- Install configuration: "Release"
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/pkgconfig/librabbitmq.pc
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/librabbitmq.so.4.2.1
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/librabbitmq.so.4
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/librabbitmq.so
-- Up-to-date: /usr/local/lib/x86_64-linux-gnu/librabbitmq.a
-- Up-to-date: /usr/local/include/amqp.h
-- Up-to-date: /usr/local/include/amqp_framing.h
-- Up-to-date: /usr/local/include/amqp_tcp_socket.h
-- Up-to-date: /usr/local/include/amqp_ssl_socket.h
The library files are installed into
/usr/local/lib/x86_64-linux-gnu/ (librabbitmq.so and librabbitmq.so.4 points as links to librabbitmq.so.4.2.1, and there is librabbitmq.a)
/usr/local/include/, where all needed header files are resides (amqp.h
amqp_framing.h amqp_ssl_socket.h amqp_tcp_socket.h)
2. Use gcc.
gcc -Wall -I/usr/local/include -L/usr/local/lib/x86_64-linux-gnu -o
storeman storeman.c -lrabbitmq
GCC exits with:
error while loading shared libraries: librabbitmq.so.4: cannot open shared object file: No such file or directory
In the same time it may succesfully be compiled as static, using librabbitmq.a, that confuses me a lot... Will be very gratefull for any help.
It looks to me like the issue may be that file /etc/ld.so.conf.d/rabbitmq.conf is missing the .../lib/... subdirectory in its content. When I update that file's content to this it works for me (finds the rabbitmq shared lib):
/usr/local/lib/x86_64-linux-gnu
Note, run sudo ldconfig after saving the change.
This appears to be a rabbitmq git installation bug - I cloned and built from branch master on Feb 22, 2018 on Ubu-17.
Related
I downloaded tdm gcc 10.3.0 and installed it succesfully. I have a file I want to compile yet it is missing header files. Is there a way to add components to tdm gcc from an interface, or do I download the files(headers) manually and add them to the project. If so, where do I add them in the project ? I know header files exist in C:\TDM-GCC-32\include
Also, just in case, I have these header files in my main.c,
#include <winsock2.h>
#include <Windows.h>
#include <ws2ipdef.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <bcrypt.h>
#include <wincrypt.h>
#include <sysinfoapi.h>
#include <winternl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
as i tried to compile with gcc main.c, I got this error
main.c:8:10: fatal error: ws2ipdef.h: No such file or directory
8 | #include <ws2ipdef.h>
| ^~~~~~~~~~~~
compilation terminated.
How can I find this header file? If I just find it in github is it enough to add it to C:\TDM-GCC-32\include ?
another way to ask, how can I add ws2 to tdm gcc, or how to install tdm gcc alongwith?
I'm trying to run a Visual Studio cpp project created by a friend of mine. I'm trying to run the file without VS. But I'm getting a list of errors, all in the same format:
inlining failed in call to always_inline '__m256d _mm256_broadcast_sd(const double*)': target specific option mismatch|
It runs correctly in VS with release mode and breaks when run in debug mode.
The includes are as follows:
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <vector>
# include <omp.h>
#include <chrono>
#include <fstream>
#include <algorithm>
#include <immintrin.h>
using namespace std::chrono;
using namespace std;
and the error is called from here:
double zero = 0;
__m256d acc = _mm256_broadcast_sd(&zero);
Update:
I'm using the this command to run it: g++ -std=c++0x multip.cpp -o multip, is there an additional parameter to add -mavx to the compiler invocation?
"Target specific option mismatch" means that you're missing a feature flag from your GCC invocation. You probably need to add -mavx to your compiler invocation.
If you're intending to run this on your computer only, -march=native will turn on all the feature flags that your own machine supports.
I'm taking some working code (that I didn't write and the creator is not around anymore) to try and get it to compile on my Mac (10.9.5) using terminal. I'm getting the following error when compiling (gcc -o code code.c):
Undefined symbols for architecture x86_64:
"_add_history", referenced from:
_rl_gets in talk-c856c6.o
"_read_history", referenced from:
_main in talk-c856c6.o
"_readline", referenced from:
_rl_gets in talk-c856c6.o
"_write_history", referenced from:
_rl_gets in talk-c856c6.o
ld: symbol(s) not found for architecture x86_64
here are all my includes:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <strings.h>
#include <readline/readline.h>
#include <readline/history.h>
I've found here and elsewhere online similar issues and have tried
#include <readline.h>
but get fatal error: 'readline.h' file not found
(same for #include <libedit.dylib>)
I'm a bit of a novice with external libraries so maybe I need to install another one? Is my issue just that the mac needs an additional library installed to use those 5 functions creating errors, or are one of my #includes only for Linux and not for Mac? I thought since both the Mac and the Linux are using Unix it would be the same, but apparently there are subtleties I don't understand.
Thanks in advance.
Did you bass the correct flags to the compiler? Seems like you are not linking against the libedit. Try passing -ledit to the compiler and tell us if that helps.
#include <libedit.dylib>
This is never correct. You can't #include a library, you need to tell the compiler that you want to link against this library when invoking it.
I am trying to compile a kernel module for using the SD card port for communicating with another peripheral (a digital signal processor TigerSHARC) to a Colibri PXA320 board. The kernel source uses the functions mmc_power_up and mmc_power_off for controlling the port and runs using the mmc driver provided in the kernel.
The source code right now has the following includes
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/types.h>
#include <linux/scatterlist.h>
#include <linux/slab.h>
#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sd.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/sdio_func.h>
#include <linux/mmc/sdio_ids.h>
#include <linux/gpio.h>
The path variables added are
export PATH=$KSRCPATH/tools/usr/local/arm/oe/bin:$PATH
export PATH=$KSRCPATH/tools/usr/local/arm/oe/arm-angstrom-linux-gnueabi/include:$PATH
export PATH=$KSRCPATH/src/linux-2.6.35.9-toradex:$PATH
export PATH=$KSRCPATH/src/linux-2.6.35.9-toradex/include/asm-arm:$PATH
export PATH=$KSRCPATH/src/linux-2.6.35.9-toradex/drivers/mmc/core:$PATH
export PATH=$KSRCPATH/src/u-boot-2010.09-toradex/tools:$PATH
where $KSRCPATH is the kernel source folder.
When I compile the kernel modules I am getting the following message :
WARNING: "mmc_set_bus_width" [/mnt/hgfs/Colibri_Linux/Linux/SDIO_Driver/unet_sdio.ko] undefined!
WARNING: "mmc_power_up" [/mnt/hgfs/Colibri_Linux/Linux/SDIO_Driver/unet_sdio.ko] undefined!
WARNING: "mmc_power_off" [/mnt/hgfs/Colibri_Linux/Linux/SDIO_Driver/unet_sdio.ko] undefined!
I checked the kernel source tree and the function s are defined in the core.c file in $KSRCPATH/src/linux-2.6.35.9-toradex/drivers/mmc/core but they dont have any declarations defined in core.h for them.
My makefile right now is :
KDIR = $(KSRCPATH)/src/linux-2.6.35.9-toradex
obj-m += unet_sdio.o
all:
make -C $(KDIR) M=$(PWD) modules
make install
clean:
make -C $(KDIR) M=$(PWD) clean
install:
cp unet_sdio.ko /mnt/hgfs/Colibri_Linux/
I have declared the functions are extern in my source code
/*! External (MMC) Functions */
extern void mmc_power_up(struct mmc_host *host);
extern void mmc_power_off(struct mmc_host *host);
I am guessing my kernel module in not getting linked into core.c in $KSRCPATH/src/linux-2.6.35.9-toradex/drivers/mmc/core and hence the functions are marked as undefined.
What changes do I need to make in the source code or the makefile to link the my source code and core.c together.
EDIT: I am able to boot the colibri PXA320 device with the compiled kernel and kallsyms does show that the mmc_power_off and mmc_power_on functions are available in the kernel on the colibri PXA320 device:
root#toradex:/home/modem# grep mmc_power* /proc/kallsyms
c0226a50 t mmc_power_off
c0226ce0 t mmc_power_up
c02277ec T mmc_power_save_host
c022796c T mmc_power_restore_host
c0229490 t mmc_power_restore
I am including a few header files:
#include <gsl/gsl_machine.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_cdf.h>
#include <gsl/gsl_cblas.h>
#include <gsl/gsl_sf_gamma.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_linalg.h>
#include <R.h>
#include <Rmath.h>
#include <Rembedded.h>
#include <Rdefines.h>
#include <R_ext/Lapack.h>
#include <R_ext/Linpack.h>
I am able to link the blas and gsl libraries using the following command (the -lm is for math?):
gcc -arch x86_64 myfile.c -o myfile -lgsl -lm -lgslcblas
But I get error:
myfile.c:21:15: error: R.h: No such file or directory
myfile.c:22:19: error: Rmath.h: No such file or directory
myfile.c:23:23: error: Rembedded.h: No such file or directory
myfile.c:24:22: error: Rdefines.h: No such file or directory
myfile.c:25:26: error: R_ext/Lapack.h: No such file or directory
myfile.c:26:27: error: R_ext/Linpack.h: No such file or directory
How do I link the header files when compiling my C code?
Header files aren't linked, only included. The errors mean just what they say: the compiler can't find them. Make sure they are in the standard include directory. Maybe you didn't make install the R library. If the header files are in the same directory as your other source files include them with double-quotes instead of angle brackets:
#include "R.h"
You can add other directories to the list of standard include directories with the -I flag to GCC.