I am trying to embed tslib on an ARM system ; I cross-compiled the library, and it seemed to be okay unless for the test scripts. Indeed, they don't work at all on my arm platform because they tryed to link libraries with the path from the compiling platform.
Here is my example : I compiled from /home/jdl/tslib ; the bug on the arm system :
/home/ts_calibrate: cd: line 1: can't cd to /home/jdl/tslib-1.0/tests
/home/ts_calibrate: eval: line 1: /usr/local/lib/star81xx-lsdk/tools/usr/bin/arm-linux-uclibc-gcc: not found
Second line is my toolchain ; don't understand why the script is looking for the toolchain as it is supposed to be compiled ?
I saw that there is some relative link during compilation :
/bin/sh ../libtool --tag=CC --mode=link /usr/local/lib/star81xx-lsdk/tools/usr/bin/arm-linux-uclibc-gcc -DGCC_HASCLASSVISIBILITY --sysroot=/usr/local/lib/star81xx-lsdk/tools --sysroot=/usr/local/lib/star81xx-lsdk/tools -o ts_harvest ts_harvest.o fbutils.o testutils.o font_8x8.o font_8x16.o ../src/libts.la -ldl
libtool: link: /usr/local/lib/star81xx-lsdk/tools/usr/bin/arm-linux-uclibc-gcc -DGCC_HASCLASSVISIBILITY --sysroot=/usr/local/lib/star81xx-lsdk/tools --sysroot=/usr/local/lib/star81xx-lsdk/tools -o .libs/ts_harvest ts_harvest.o fbutils.o testutils.o font_8x8.o font_8x16.o ../src/.libs/libts.so -ldl
Do you have an idea for what goes wrong ?
Thanks
Sorry for the waste of time, I found my answer just after posting >< There is a .libs dir into the tests dir that contains the good versions of test softs. ;)
Related
I was asked to create a C-Function to integrate with Postgres. The Postgres documentation to this kind of function is available here: Postgres documentation.
The function I am trying to compile is from the manual and it is called add_one, just for test. But I had a problem while compiling it. The command I followed of the documentation was:
cc -fPIC -c foo.c
cc -shared -o foo.so foo.o
And the problem it returned was:
[igoralberte#localhost inside-postgres]$ cc -fPIC -c serializacao.c
serializacao.c:1:10: fatal error: postgres.h: Arquivo ou diretório inexistente
#include "postgres.h"
^~~~~~~~~~~~
compilation terminated.
In English, it means: Non-existent file or directory (postgres.h).
I have tried to copy some files I thought were important to /usr/lib directory. They were on /usr/include/pgsql or on /lib64. Those files were:
libpq.so
libpq.so.5
libpq.so.5.13
libpq (directory)
postgres_ext.h
Some important informations about my system:
I am using CentOS 8
System architecture: x86-64
GCC version: gcc (GCC) 8.4.1 20200928 (Red Hat 8.4.1-1)
Postgres version: 13.3
Thanks in advance!
It is a bold step to write a postgres plugin before you have a solid grasp on linux/unix, shell programming and how to compile c programs.
Typically your c compiler has to be told where to find header files using the -I compiler switch. So if postgres.h is in /path/containing/headerfile, you must add -I/path/containing/headerfile to the compile command:
cc -I/path/containing/headerfile -fPIC -c foo.c
The postgres documentation you linked to tells you to use pg_config --includedir-server to find out where the the header files are stored.
I am not familiar with pg_config, but if it acts like similar tools and
gives the output -I/path/containing/headerfile when calling it with the paramater --includedir-server, then you don't have to hardcode the path in your compile command. But just write:
cc `pg_config --includedir-server` -fPIC -c foo.c
See "Command Substitution" in your favorite shell documentation.
I also recommend learning how to use a build-tool like make. Things are soon going to be tedious if you have to retype compilation and link commands all the time.
Oh, and by the way, you probably want to write #include <postgres.h> and not #include "postgres.h" (Unless you are a postgres contributor and postgres.h is part of your project files)
I have an application that links again SDL and cairo that I would like to cross-compile on ubuntu for win64. I used this excellent blog post to get SDL cross compiling and I've used another blog post to cross-compile zlib, libpng and libpixman.
However, I now get a linker error trying to compile my minimal test program:
$ make cairotest.exe
x86_64-w64-mingw32-gcc -o cairotest.o -c cairotest.c -I/usr/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main -I/home/jshaw/x86_64-w64/include/cairo -I/home/jshaw/x86_64-w64/include/pixman-1 -I/home/jshaw/x86_64-w64/include/libpng16
x86_64-w64-mingw32-gcc -o cairotest.exe cairotest.o -L/usr/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -L/home/jshaw/x86_64-w64/lib -lcairo
collect2: error: ld returned 1 exit status
Makefile:13: recipe for target 'cairotest.exe' failed
I should mention that this test program works correctly if I just use SDL2 without any cairo code, so I suspect something is wrong with the cairo library that I cross-compiled. How should I go about diagnosing the problem?
Looking at your Makefile it appears as though your are using normal pkg-config for discovering your Cairo libs. CAIRO_LDFLAGS := $(shell $(PKG_CONFIG) cairo --libs). This will find the path to your host libraries, which is presumably a different architecture than the target. An architecture mismatch like that can really cause strange problems with the linker. I believe you should be looking for something like usr/x86_64-w64-mingw32/bin/pkg-config.
Other things to try;
Run the compilation commands manually, as the makefile could be suppressing output.
Also, when running the command, add the -v flag to the command line to get the verbose output to better figure out where the issue is.
I have installed eCos OS on a linux system (Ubuntu 13.02). After installation, the eCos files are located in opt/ecos.
As I read the eCos tutorial, I see hello.c is stored in opt/ecos/ecos-3.0/examples/hello.c (And I notice that maybe all main eCos system files store in the ecos-3.0 directory).
I have followed the eCos tutorial found on the official website, but I still cannot successfully compile hello.c.
More detail. When I try to run :
$ export INSTALL_DIR=BASE_DIR/ecos-work/arm_install
$ TARGET-gcc -g -IBASE_DIR/ecos-work/install/include hello.c \
-LBASE_DIR/ecos-work/install/lib -Ttarget.ld -nostdlib
I get the error : TARGET-gcc : command not found
I have tried some other tutorials, but I'm still having issues (too messy to list here).
I am looking for step-by-step instruction on compiling hello.c in eCos system. I see the eCos manual lacking in this area.
Thanks :)
It appears that you've missed a subtle convention in the eCos documentation. Items in italics are provided by you! They are variables.
The documentation mentions this here:
Note: Remember that when this manual shows TARGET-gcc you should use
the full name of the cross compiler, e.g. i386-elf-gcc, arm-elf-gcc,
or sh-elf-gcc. When compiling for the synthetic Linux target, use the
native gcc which must have the features required by eCos.
Replace TARGET with the appropriate value and BASE_DIR with (I think, in your case) /opt/ecos. You should verify the include directory before moving forward:
$ ls -l /opt/ecos/ecos-work/install/include
If that doesn't list directory contents, then you simply need to locate ecos-work
The Ecosconfig on Windows and Linux Quick Start section of the docs has you create the BASE_DIR directory (below is a snippet that I am quoting ... italics will not display).
$ mkdir BASE_DIR/ecos-work
$ cd BASE_DIR/ecos-work
So, this could be the correct invocation.
$ export INSTALL_DIR=/opt/ecos/ecos-work/arm_install
$ arm-elf-gcc -g -I/opt/ecos/ecos-work/install/include hello.c \
-L/opt/ecos/ecos-work/install/lib -Ttarget.ld -nostdlib
you need to do
# source /opt/ecos/ecosenv.sh
Then you can try to compile by changing TARGET=
$ TARGET-gcc -g -IBASE_DIR/ecos-work/install/include hello.c \
-LBASE_DIR/ecos-work/install/lib -Ttarget.ld -nostdlib
I've ten ".o" files in a directory.i want to combine them as a shared lib (.so) file.
For doing so,I am issuing following command
#gcc -shared *.o -o abc.so
but it throws following error message:
No command '-shared' found, did you mean:
Command 'gshared' from package 'gshare' (universe)
-shared: command not found
What could be the possible reason? Anything wrong with the command?
Any help ?
I agree with Chen Levy. It looks like gcc is either a stange version or not what you think it is. When I do:
gcc -shared *.o -o abc.so
I get the desired reponse. Try echo, or even:
which gcc
to try and see what's really going on. PS: I Tested on Ubuntu 10.10
This probably very easy when you know how, but I don't :)
I'm trying to build some code that takes uses opengl/glut. I'm using the cygwin version of cmake opengl etc. The only reference I see to opengl/gult is in the CMakeLists.txt:
find_package(OpenGL REQUIRED)
find_package(GLU REQUIRED)
find_package(GLUT REQUIRED)
Everything works fine up till the linking stage, which ends with:
CMakeFiles/glview.dir/glview.c.o: In function `DrawGLScene': /cygdrive/C/code/libfreenect/examples/glview.c:88: undefined reference to `__imp__glutSwapBuffers#0'
CMakeFiles/glview.dir/glview.c.o: In function `keyPressed': /cygdrive/C/code/libfreenect/examples/glview.c:96: undefined reference to `__imp
etc.
After a git of googling I figured out this because cmake is feading the linker a -lglut flag, when it should be feading it a -lgut32 flag. By manually executing the linking command, I can get the program to build:
/usr/bin/gcc.exe -Wall -O3 -g -Wl,--enable-auto-import CMakeFiles/glview.dir/glview.c.o -o glview.exe -Wl,--out-implib,libglview.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -L/cygdrive/C/code/libfreenect/lib ../lib/libfreenect.a -lGL -lGLU -lglut32 -lm -lpthread -lusb-1.0
But I can't figure out how to get cmake to generate this command for me so no manual steps are needed. Any ideas what I should be doing?
Cheers,
Rob
this is how to add libraries to link to:
target_link_libraries( ${TargetName} gut32 )
find_package only assures the package is found, no more.