building project with libcurl doesn't work under linux - c

i am attempting to build a little project in C under Linux in Eclipse Juno. As I include the libcurl library, I think the linker throw always the error cannot find -lcurl. I know there are several posts on the internet, but nothing really helps. The whole looks like this:
Building target: c_template
Invoking: GCC C Linker
/usr/local/oecore-i686-arm/sysroots/i686-oesdk-linux/usr/bin/armv7a-vfp-neon-oe-linux-gnueabi/arm-oe-linux-gnueabi-gcc -L/usr/lib --sysroot=/usr/local/oecore-i686-arm/sysroots/armv7a-vfp-neon-oe-linux-gnueabi -o "c_template" ./src/atCommand.o ./src/charDevice.o ./src/curl.o ./src/debug.o ./src/linux_prototype.o ./src/output.o ./src/simStatus.o ./src/urc.o ./src/wwan.o -lpthread -lcurl
from <command-line>:0:
/home/ubuntu/Documents/eCall/hwell_06/workspace_hwell_06/c_template/inc/defs.h:87:10: warning: type defaults to 'int' in declaration of 'BOOL' [-Wimplicit-int]
/home/ubuntu/Documents/eCall/hwell_06/workspace_hwell_06/c_template/inc/atCommand.h:56:12: warning: 'atCommandsHandler' defined but not used [-Wunused-variable]
/home/ubuntu/Documents/eCall/hwell_06/workspace_hwell_06/c_template/inc/debug.h:60:12: warning: 'deviceHandler' defined but not used [-Wunused-variable]
/usr/local/oecore-i686-arm/sysroots/i686-oesdk-linux/usr/libexec/armv7a-vfp-neon-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.6.3/ld: warning: skipping incompatible /usr/lib/libpthread.so while searching for pthread
/usr/local/oecore-i686-arm/sysroots/i686-oesdk-linux/usr/libexec/armv7a-vfp-neon-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.6.3/ld: warning: skipping incompatible /usr/lib/libcurl.so while searching for curl
/usr/local/oecore-i686-arm/sysroots/i686-oesdk-linux/usr/libexec/armv7a-vfp-neon-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.6.3/ld: error: cannot find -lcurl
/usr/local/oecore-i686-arm/sysroots/i686-oesdk-linux/usr/libexec/armv7a-vfp-neon-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.6.3/ld: warning: skipping incompatible /usr/lib/libc.so while searching for c
../src/curl.c:66: error: undefined reference to 'curl_global_init'
../src/curl.c:69: error: undefined reference to 'curl_easy_init'
../src/curl.c:72: error: undefined reference to 'curl_slist_append'
../src/curl.c:73: error: undefined reference to 'curl_slist_append'
../src/curl.c:76: error: undefined reference to 'curl_easy_setopt'
../src/curl.c:79: error: undefined reference to 'curl_easy_setopt'
../src/curl.c:82: error: undefined reference to 'curl_easy_setopt'
../src/curl.c:85: error: undefined reference to 'curl_easy_setopt'
../src/curl.c:98: error: undefined reference to 'curl_easy_perform'
../src/curl.c:101: error: undefined reference to 'curl_easy_strerror'
../src/curl.c:105: error: undefined reference to 'curl_slist_free_all'
../src/curl.c:108: error: undefined reference to 'curl_easy_cleanup'
../src/curl.c:112: error: undefined reference to 'curl_global_cleanup'
collect2: ld returned 1 exit status
make: *** [c_template] Error 1
I already set up the paths for the library for the linker:
For the library search path (-L) : /usr/lib
and for libraries (-l): curl
My command line pattern looks like this:
${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}
Can anyone helps me. Would be great.
Thanks a lot

You're crosscompiling c_template for ARM so you'll need to install the libcurl for ARM in your cross-compile environment. Right now it finds the libcurl for your i686 host and it cannot use that as shown in:
/usr/local/oecore-i686-arm/sysroots/i686-oesdk-linux/usr/libexec/armv7a-vfp-neon-oe-linux-gnueabi/gcc/arm-oe-linux-gnueabi/4.6.3/ld: warning: skipping incompatible /usr/lib/libcurl.so while searching for curl
So first compile/install libcurl for your target platform in your compile environment and make sure your compiler can find that.

Related

Sqlite amalgamation C file doesn't compile on Raspbian

I am using a Raspberry Pi to run a C program that interacts with a can interface, and stores values in a database as part of a project.
I started C one month ago, and I am still a bit lost with everything.
Description of my workspace and problem :
I have my test file test virtual.c that includes a homemade file handler_code.c that includes the sqlite3.c amalgamation file(via #include "sqlite3.c").
Then I have a CMakeLists.txt that was provided to me :
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
set( STANDALONE TRUE )
cmake_minimum_required(VERSION 3.13)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(CARLOS REQUIRED)
else()
include_directories(${CMAKE_SOURCE_DIR}/core/include)
include_directories(${CMAKE_BINARY_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/gui/include)
endif()
add_definitions(-DRESOURCES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/resources")
add_executable(test_example "test virtual.c")
target_link_libraries(test_example carlos)
set_target_properties(
test_example
PROPERTIES
C_STANDARD 99
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/examples_bin
)
It imports all libraries I need. All the files are in the same directory.
I then go in the subdirectory build and run cmake .. which succeeds and then make. This is what happens :
pi#raspberrypi:~/Desktop/examples/build $ make
[ 50%] Building C object CMakeFiles/test_example.dir/test_virtual.c.o
In file included from /home/pi/Desktop/examples/handler_code.c:5,
from /home/pi/Desktop/examples/test virtual.c:8:
/home/pi/Desktop/examples/sqlite3.c:34058:42: error: ‘mremap’ undeclared here (not in a function); did you mean ‘munmap’?
{ "mremap", (sqlite3_syscall_ptr)mremap, 0 },
^~~~~~
munmap
/home/pi/Desktop/examples/sqlite3.c: In function ‘unixRemapfile’:
/home/pi/Desktop/examples/sqlite3.c:38625:42: error: ‘MREMAP_MAYMOVE’ undeclared (first use in this function)
pNew = osMremap(pOrig, nReuse, nNew, MREMAP_MAYMOVE);
^~~~~~~~~~~~~~
/home/pi/Desktop/examples/sqlite3.c:38625:42: note: each undeclared identifier is reported only once for each function it appears in
/home/pi/Desktop/examples/sqlite3.c:38625:42: warning: passing argument 4 of ‘(void * (*)(void *, size_t, size_t, int, ...))aSyscall[24].pCurrent’ makes integer from pointer without a cast [-Wint-conversion]
/home/pi/Desktop/examples/sqlite3.c:38625:42: note: expected ‘int’ but argument is of type ‘struct unix_syscall *’
make[2]: *** [CMakeFiles/test_example.dir/build.make:63: CMakeFiles/test_example.dir/test_virtual.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/test_example.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
I tried only compiling sqlite3.c with gcc and I got this :
pi#raspberrypi:~/Desktop/examples $ gcc sqlite3.c
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/crt1.o: in function `_start':
(.text+0x34): undefined reference to `main'
/usr/bin/ld: /tmp/cc6Quw7S.o: in function `pthreadMutexAlloc':
sqlite3.c:(.text+0x5098): undefined reference to `pthread_mutexattr_init'
/usr/bin/ld: sqlite3.c:(.text+0x50a8): undefined reference to `pthread_mutexattr_settype'
/usr/bin/ld: sqlite3.c:(.text+0x50c8): undefined reference to `pthread_mutexattr_destroy'
/usr/bin/ld: /tmp/cc6Quw7S.o: in function `pthreadMutexTry':
sqlite3.c:(.text+0x51b8): undefined reference to `pthread_mutex_trylock'
/usr/bin/ld: /tmp/cc6Quw7S.o: in function `sqlite3ThreadCreate':
sqlite3.c:(.text+0x9fcc): undefined reference to `pthread_create'
/usr/bin/ld: /tmp/cc6Quw7S.o: in function `sqlite3ThreadJoin':
sqlite3.c:(.text+0xa084): undefined reference to `pthread_join'
/usr/bin/ld: /tmp/cc6Quw7S.o: in function `unixDlOpen':
sqlite3.c:(.text+0x148c0): undefined reference to `dlopen'
/usr/bin/ld: /tmp/cc6Quw7S.o: in function `unixDlError':
sqlite3.c:(.text+0x148f4): undefined reference to `dlerror'
/usr/bin/ld: /tmp/cc6Quw7S.o: in function `unixDlSym':
sqlite3.c:(.text+0x14970): undefined reference to `dlsym'
/usr/bin/ld: /tmp/cc6Quw7S.o: in function `unixDlClose':
sqlite3.c:(.text+0x1498c): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
I also did some tests on my windows computer. The file named config.c includes the amalgamation just like handler_code.c did.
PS C:\Users\p107770\Desktop\projects\hmi-rapid-prototyping\C> gcc sqlite3.c
C:/MATLAB/V_R2016b/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): In function `main':
C:/crossdev/src/mingw-w64-v3-git/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
PS C:\Users\p107770\Desktop\projects\hmi-rapid-prototyping\C> gcc config.c
PS C:\Users\p107770\Desktop\projects\hmi-rapid-prototyping\C>
So here, it successfully compiles the file that includes the amalgamation file (which is what I'd want on my raspberry pi, even though it's not the same file), but it does not compile the amalgamation file alone (which I don't understand).
Ideas I found while searching
Using sqlite as a library/package in CMake file
Something looking like this. But looking at my CMake file, I realized that my sqlite amalgamation file was not a "package" in the same way CARLOS and Threads are (I installed CARLOS with .deb files provided to me). So my question here is how to transform the amalgamtion file into a package ?
Compiling sqlite so it would be imported globally
I remember reading something about this. If I recall correctly, I can compile the sqlite amalgamation file into a .dll and make it available in any C file with the #include <sqlite3.c> line instead of #include "sqlite3.c", but I don't know if it would work here because I think this was working when compiling with gcc and not with make.
Thank you in advance for any help you could bring, I can add bits of code if needed.

Is there an easier way to compile this project

Under Linux(Ubuntu) I'm writing a CMakeLists.txt with CLion to compile my project which is a little game written in C. How do I fix these errors?
Here's a link to the entire source code.
Any help will be greatly appreciated
I have tried to rewrite my .h files. It was primarily an issue about linking SDL and SDL_images.
I have tried to compile the main with gcc main.c -o main -lSDL -lSDL_image.
Here's the CMakeLists.txt
cmake_minimum_required(VERSION 3.7)
project(SOKOBAN)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lmingw32")
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
include_directories(${PROJECT_SOURCE_DIR}/include)
link_directories(${PROJECT_SOURCE_DIR}/lib)
find_package(SDL REQUIRED)
find_package(SDL)
find_package(SDL_image)
set(SOURCE_FILES main.c jeu.c jeu.h editeur.c editeur.h
fichiers.c fichiers.h Constantes.h hsokoban.h)
add_executable(SOKOBANR ${SOURCE_FILES})
target_link_libraries(SOKOBANR SDL_image SDL)
The error is:
[ 20%] Linking C executable SOKOBANR
CMakeFiles/SOKOBANR.dir/jeu.c.o: In function `jouer':
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:12: multiple definition of `jouer'
CMakeFiles/SOKOBANR.dir/main.c.o:/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:12: first defined here
/usr/bin/ld: skipping incompatible /home/mahamad/github/SOKOBAN/SOKOBAN/lib/libSDL.a when searching for -lSDL
CMakeFiles/SOKOBANR.dir/main.c.o: In function `jouer':
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:72: undefined reference to `deplacerJoueur'
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:76: undefined reference to `deplacerJoueur'
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:80: undefined reference to `deplacerJoueur'
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:84: undefined reference to `deplacerJoueur'
CMakeFiles/SOKOBANR.dir/jeu.c.o: In function `jouer':
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:72: undefined reference to `deplacerJoueur'
CMakeFiles/SOKOBANR.dir/jeu.c.o:/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:76: more undefined references to `deplacerJoueur' follow
CMakeFiles/SOKOBANR.dir/fichiers.c.o: In function `sauvegarderNiveau':
/home/mahamad/github/SOKOBAN/SOKOBAN/fichiers.c:67: undefined reference to `fprint'
collect2: error: ld returned 1 exit status
CMakeFiles/SOKOBANR.dir/build.make:128: recipe for target 'SOKOBANR' failed
make[3]: *** [SOKOBANR] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/SOKOBANR.dir/all' failed
make[2]: *** [CMakeFiles/SOKOBANR.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/SOKOBANR.dir/rule' failed
make[1]: *** [CMakeFiles/SOKOBANR.dir/rule] Error 2
Makefile:118: recipe for target 'SOKOBANR' failed
make: *** [SOKOBANR] Error 2```
If you get such errors you need to look into each of them:
CMakeFiles/SOKOBANR.dir/jeu.c.o: In function `jouer':
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:12: multiple definition of `jouer'
CMakeFiles/SOKOBANR.dir/main.c.o:/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:12: first defined here
The linker thinks that you have (at least) two definitions of jouer. Since both referenced locations are the same I assume that you 1. include "jeu.c" instead of "jeu.h" in your "main.c", and 2. link both "main.o" and "jeu.o".
/usr/bin/ld: skipping incompatible /home/mahamad/github/SOKOBAN/SOKOBAN/lib/libSDL.a when searching for -lSDL
The library "libSDL.a" you provide is not compatible to the target system. Your target system seems to be Linux.
For which system is the library?
Did you compile it yourself or did you download it?
CMakeFiles/SOKOBANR.dir/main.c.o: In function `jouer':
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:72: undefined reference to `deplacerJoueur'
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:76: undefined reference to `deplacerJoueur'
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:80: undefined reference to `deplacerJoueur'
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:84: undefined reference to `deplacerJoueur'
CMakeFiles/SOKOBANR.dir/jeu.c.o: In function `jouer':
/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:72: undefined reference to `deplacerJoueur'
CMakeFiles/SOKOBANR.dir/jeu.c.o:/home/mahamad/github/SOKOBAN/SOKOBAN/jeu.c:76: more undefined references to `deplacerJoueur' follow
There are references (calls) of deplacerJoueur but you don't define it. Or the source file with the definition (implementation) is not added to the list of modules.
CMakeFiles/SOKOBANR.dir/fichiers.c.o: In function `sauvegarderNiveau':
/home/mahamad/github/SOKOBAN/SOKOBAN/fichiers.c:67: undefined reference to `fprint'
This is clearly a typo. You mean fprintf() with a trailing 'f' for sure.
collect2: error: ld returned 1 exit status
Because of all the errors the linker is not successful, and it tells you.
CMakeFiles/SOKOBANR.dir/build.make:128: recipe for target 'SOKOBANR' failed
Because of all the errors the build is not successful, and it tells you.

Error when compiling file | collect2: error: ld returned 1 exit status

I am having a lot of problem and can't seem to make any sense of what is going on. I am trying to learn C from Learn C The Hard Way, and I am trying to compile the first exercise. When ever I run make I get a huge problem
cc ex1.c -o ex1
ex1.c: In function ‘main’:
ex1.c:3:5: warning: implicit declaration of function ‘put’ [-Wimplicit-function-declaration]
put("Hello world.");
^
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/5.3.1/../../../libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /lib/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
<builtin>: recipe for target 'ex1' failed
make: *** [ex1] Error 1
any help would be wonderful
The first error is clear; there is no declaration for a function called put(). This is either because
you have mistyped the function name,
or because you have failed to provide a declaration either directly of via a header file containing the declaration.
In this case if the code you were attempting to compile is from this exercise then look at it again - it clearly differs from your code (i.e. the first of the possibilities listed above). However even then you would get the same error; read further in the exercise and you will see that the author has deliberately omitted the header file in order to illustrate the need for the specific library header file. The reason you get the warning without the suggested -Wall command line option is probably because you are using a newer version of the compiler than the author. To be honest from what little I have seen of "Learn C the Hard Way", I would steer clear of it.
The second issue is one of your linker being unable to find an appropriate version of the standard C library to link to your code. Compiling C code in Linux is normally straightforward; most distributions come with GCC already correctly installed and working; your's appears to be horribly broken. You may want to repair your toolchain installation. You may have installed multiple incompatible toolchains.

OpenGL Compilation Errors Ubuntu

I'm trying to set up the code from
http://www.openglsuperbible.com/example-code/
with command:
$ cmake -G "Unix Makefiles" ; make clean ; make all
I've installed the following packages in order to prepare the system:
xrandr libxrandr x11-xserver-utils libxrandr-dev libglfw2 libglfw-dev xorg-dev libx11-dev libgl-dev libglu-dev libgl1-mesa-dev freeglut3 freeglut3-dev mesa-common-dev freeglut3-dev build-essential libx11-dev libx11-*
I may have missed some of the packages I've installed in this list, I apologize.
Then I've modified the CMakeList.txt in order to add to the linking phase the following things:
glfw GL rt glut X11 dl Xrandr Xext GLEW GLU
Then I try to compile, but it fails at the linking phase:
/opt/sb6code/src/xraw/xraw.c: In function ‘CreateWindow’:
/opt/sb6code/src/xraw/xraw.c:106:14: warning: assignment makes pointer from integer without a cast [enabled by default]
Linking C executable bin/xraw
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function CreateWindow: error: undefined reference to 'XOpenDisplay'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function CreateWindow: error: undefined reference to 'XCloseDisplay'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function CreateWindow: error: undefined reference to 'XCreateColormap'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function CreateWindow: error: undefined reference to 'XCreateWindow'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function CreateWindow: error: undefined reference to 'XMapWindow'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function CreateWindow: error: undefined reference to 'glXCreateContextAttribsARB'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function Cleanup: error: undefined reference to 'XDestroyWindow'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function Cleanup: error: undefined reference to 'XCloseDisplay'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function main: error: undefined reference to 'XNextEvent'
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function main: error: undefined reference to 'XGetWindowAttributes'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/xraw] Errore 1
make[1]: *** [CMakeFiles/xraw.dir/all] Errore 2
make: *** [all] Errore 2
Now, I've tried to search the web and even here on SO.com for solutions, but they keep telling me to link the libraries I've already added to the linking phase.. so I can't seem to make any more progress.
Do you happen to have some knowledge or hint that could help me?
Ok, stimulated by answers I've gone into CMakeFiles directory and looked for the configuration file that manages the compilation. I've found out that for some reasons it did miss some of the flags stated into the CMakeLists despite of my update.
So now the compilation line looks like:
/usr/bin/cc CMakeFiles/xraw.dir/src/xraw/xraw.c.o -o bin/xraw -L/opt/sb6code/lib -rdynamic -lGL -lglut -lGLU -lm -lX11 -ldl -lGLEW -lXrandr -lXext -lrt -lglfw -Wl,-rpath,/opt/sb6code/lib
And the errors have reduced to :
CMakeFiles/xraw.dir/src/xraw/xraw.c.o:xraw.c:function CreateWindow: error: undefined reference to 'glXCreateContextAttribsARB'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/xraw] Errore 1
make[1]: *** [CMakeFiles/xraw.dir/all] Errore 2
make: *** [all] Errore 2
Other hints? :)
Side Note:
I've also installed CUDA libraries and under path
/usr/lib/nvidia-304/
I happen to have
alt_ld.so.conf libnvidia-ml.so.1
bin/ libnvidia-ml.so.304.88
ld.so.conf libnvidia-opencl.so.1
libcuda.so libnvidia-opencl.so.304.88
libcuda.so.1 libnvidia-tls.so.304.88
libcuda.so.304.88 libnvidia-wfb.so.1
libGL.so libnvidia-wfb.so.304.88
libGL.so.1 libOpenCL.so
libGL.so.304.88 libOpenCL.so.1
libnvcuvid.so libOpenCL.so.1.0
libnvcuvid.so.1 libOpenCL.so.1.0.0
libnvcuvid.so.304.88 libXvMCNVIDIA_dynamic.so.1
libnvidia-cfg.so libXvMCNVIDIA.so
libnvidia-cfg.so.1 libXvMCNVIDIA.so.1
libnvidia-cfg.so.304.88 libXvMCNVIDIA.so.304.88
libnvidia-compiler.so tls/
libnvidia-compiler.so.1 vdpau/
libnvidia-compiler.so.304.88 xorg/
libnvidia-glcore.so.304.88 XvMCConfig
libnvidia-ml.so
Which I would like to use since I'm not sure that my intel graphic card supports OpenGl 4.* which I shall use with the book, while the nvidia one supports 4.2.
I really can't find any good how to on the matter, the Book conveniently avoids to give installation instructions.
Temporary Solution:
I've found out that this is the only source file that does not work. Removing its files and CMakeList.txt configuration seems to be wise until someone finds out another solution.
Also, i had to use optirun to run the executables, in case other people with bumblebee/nvidia are wondering why their programs do not work.
You probably link the libraries in wrong order; all these symbols are defined in libX11.a; you should want to see what is the actual linking command line fed to GCC, and post it here.
Update now it means that you are statically trying to link against an API function that is not available in your libs (it is an optional extension and should be queried dynamically).

Contiki RTOS hello-world fails

Hello there I am trying to execute the example programs included as part of the Contiki RTOS package. I tried executing the hello-world program by using the command: make TARGET=cooja clean and then typed make TARGET=cooja, and this resulted in the following output on the terminal:
I../../core/loader -I../../core/. -DAUTOSTART_ENABLE -c hello-world.c -o hello-world.co
hello-world.c: In function ‘process_thread_hello_world_process’:
hello-world.c:52:3: warning: variable ‘PT_YIELD_FLAG’ set but not used [-Wunused-but-set-variable]
ld hello-world.co contiki-cooja.a -o hello-world.cooja
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048094
contiki-cooja.a(log.o): In function `simlog':
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:78: undefined reference to `strlen'
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:83: undefined reference to `strlen'
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:83: undefined reference to `memcpy'
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:84: undefined reference to `strlen'
contiki-cooja.a(log.o): In function `printf':
/home/contiki/contiki-2.5/examples/hello-world/../../platform/cooja/sys/log.c:128: undefined reference to `vsnprintf'
make: *** [hello-world.cooja] Error 1
rm hello-world.co
root#ubuntu:/home/contiki/contiki-2.5/examples/hello-world#
Can someone please let me know as to where I am going wrong with the flow. I have made no changes to the original example codes and I intend to get the programs working on the COOJA simulator..thanks

Resources