NASM printf Ubuntu 64-bit v12.04 - c

I'm trying to use printf statement in NASM. I tried to assemble and link this code with command given in comment of the code, but terminal shows following error:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: ld returned 1 exit status
Why am I getting this error?

Related

ld finds library when run stand along but cant find when building executable

I am trying to build a program that requires the linking of libndctl. However, ld fails to find the library, and the build errors out at the linking stage stating (this used to build without error some time before):
Command:
g++ tatp_db.cc tatp_nvm.cc ../include/txopt.cc -lpmem -lpthread -o tatp_nvm -std=c++11 -static
Error:
/usr/bin/ld: /usr/local/lib/libpmem.a(libpmem_all.o): in function `pmem2_device_dax_alignment':
memset_t_avx512f.c:(.text+0xb527): undefined reference to `ndctl_new'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xb59e): undefined reference to `ndctl_namespace_get_dax'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xb5b5): undefined reference to `ndctl_dax_get_align'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xb5ce): undefined reference to `ndctl_unref'
/usr/bin/ld: /usr/local/lib/libpmem.a(libpmem_all.o): in function `pmem2_device_dax_size':
memset_t_avx512f.c:(.text+0xb62f): undefined reference to `ndctl_new'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xb6a9): undefined reference to `ndctl_namespace_get_dax'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xb6c0): undefined reference to `ndctl_dax_get_size'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xb700): undefined reference to `ndctl_unref'
/usr/bin/ld: /usr/local/lib/libpmem.a(libpmem_all.o): in function `pmem2_region_namespace':
memset_t_avx512f.c:(.text+0xc3ab): undefined reference to `ndctl_bus_get_first'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc3c0): undefined reference to `ndctl_region_get_first'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc3d5): undefined reference to `ndctl_namespace_get_first'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc3f2): undefined reference to `ndctl_namespace_get_dax'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc41e): undefined reference to `ndctl_dax_get_daxctl_region'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc463): undefined reference to `daxctl_dev_get_first'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc475): undefined reference to `daxctl_dev_get_devname'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc4e1): undefined reference to `daxctl_dev_get_next'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc512): undefined reference to `ndctl_namespace_get_btt'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc529): undefined reference to `ndctl_btt_get_block_device'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc53b): undefined reference to `ndctl_namespace_get_pfn'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc552): undefined reference to `ndctl_pfn_get_block_device'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc564): undefined reference to `ndctl_namespace_get_block_device'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc5d1): undefined reference to `ndctl_namespace_get_next'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc5ec): undefined reference to `ndctl_region_get_next'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc607): undefined reference to `ndctl_bus_get_next'
/usr/bin/ld: /usr/local/lib/libpmem.a(libpmem_all.o): in function `pmem2_get_region_id':
memset_t_avx512f.c:(.text+0xc64f): undefined reference to `ndctl_new'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc6f8): undefined reference to `ndctl_region_get_id'
/usr/bin/ld: memset_t_avx512f.c:(.text+0xc70a): undefined reference to `ndctl_unref'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: all] Error 1
I tried fixing this by manually adding -lndctl to the build command
g++ tatp_db.cc tatp_nvm.cc ../include/txopt.cc -lpmem -lpthread -lndctl -o tatp_nvm -std=c++11 -static
Error:
/usr/bin/ld: cannot find -lndctl
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: all] Error 1
I see that the library exists in /usr/lib/ and when running ld stand-alone (/usr/bin/ld -lndctl --verbose) it finds the library. Does anyone know what causes this to happen and a fix?
Command:
g++ tatp_db.cc tatp_nvm.cc ../include/txopt.cc -lpmem -lpthread -o tatp_nvm -std=c++11 -static
That command is wrong: you said yourself that this binary requires libndtcl, yet you aren't listing that library on the command line, so of course its symbols end up being unresolved.
I tried fixing this by manually adding -lndctl to the build command
That is the correct fix.
/usr/bin/ld: cannot find -lndctl
I see that the library exists in /usr/lib/
There are a few likely root causes:
If you are linking a 64-bit executable (which seems likely), /usr/lib/libndctl* may exist, but is a 32-bit binary.
You need a 64-bit version (usually found in /usr/lib64) and that version is not present.
You have only libndctl.so*, but not libndtcl.a (the latter is required for -static link).
To fix, you would need to install libndctl-dev or similar package.

How to build a 32bit app using Cygwin64 and Clang?

I have successfully compiled and linked some C code with Windows+Cygwin64+Eclipse+LLVM toolchain.
I wanted to build a 32bit version, so I added -m32 flag to compiler and linker, but ended up with errors:
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/libcygwin.a when searching for -lcygwin
/usr/bin/ld: skipping incompatible /usr/lib/libcygwin.a when searching for -lcygwin
/usr/bin/ld: skipping incompatible /usr/lib/libcygwin.a when searching for -lcygwin
/usr/bin/ld: cannot find -lcygwin
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/bin/ld: cannot find -ladvapi32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/bin/ld: cannot find -lshell32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/bin/ld: cannot find -luser32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/bin/ld: cannot find -lkernel32
/usr/bin/ld: cannot find crtend.o: No such file or directory
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
Is it possible to build a 32-bit app with 64-bit Cygwin?
You have to install the 32-bit versions of the libraries.
You have to install the package cygwin32-gcc-core to get all libraries+ the compiler. Then you have to invoke gcc for 32 bit as i686-pc-cygwin-gcc, as gcc is normally a link to x86_64-pc-cygwin-gcc.

GCC cannot find -lSDL2

i am trying to compile Xash3d from https://github.com/FWGS/xash3d (an open source hl1 engine), i am using ubuntu 16 64 bits and when running the makefile i get this error:
/usr/bin/ld: skipping incompatible /usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../libSDL2.so when searching for -lSDL2
/usr/bin/ld: skipping incompatible /usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../libSDL2.a when searching for -lSDL2
/usr/bin/ld: skipping incompatible //usr/local/lib/libSDL2.so when searching for -lSDL2
/usr/bin/ld: skipping incompatible //usr/local/lib/libSDL2.a when searching for -lSDL2
/usr/bin/ld: cannot find -lSDL2
/usr/bin/ld: skipping incompatible /usr/local/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
Makefile.linux:107: recipe for target 'xash' failed
make: *** [xash] Error 1
I have installed the libsdl2-dev package for both, 32 and 64 bits.
This is the makefile out:
gcc -g -o xash -fvisibility=hidden -m32 ... -lm -lSDL2 -pthread -lX11 -ldl
I have also try to compile other projects with the flag -lSDL2 and they compile just fine.
Any clue?

Compiling a c program on a 64 bit machine with a 32 bit binary

I am currently trying to use the libssh.dll library to implement a c program that shall connect to remote computers.I am using gcc to compile the program. When compiling this program, I received this error:
i386 architecture of input file 'libssh/bin/libssh.ddl' is incompatible with i386:x86-64 output
I tried compiling the program with the -m32 flag, but then i receive these errors:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.8.2//libgcc_s.dll.a when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.8.2//libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../libcygwin.a when searching for -lcygwin
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.8.2/libgcc_s.dll.a when searching for -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/4.8.2//libgcc.a when searching for -lgcc
Any ideas how to fix this issue?
You need to install the 32-bit version of the C library.
The 32-bit libraries are required if you want to be able to compile and link with the -m32 option.
Have you installed cygwin32 ?

Why does libSDL_draw.[so/a] is not find when I lauch make?

I'm trying to compile a C code which need SDL libraries(v1.2), SDL_draw and a library imposed by my teacher. the .c and makefile code works on an other computer.
I use a makefile and when I 'make' I get severals errors :
- first SDL_draw cannot be find although I paste it in /usr/include/2011/lib/libSDL_draw.a
- all other libraire are 'skipping incompatible' (I hope that those are just warnings)
- I though that it was compiled in static and the .so wouldn't be needed.
And I wondered what is the mysterious variable LFLMAC.
/outup given by terminal/
gcc -o demo1 demo1.o -g -L/usr/include/2011/lib -L/usr/local/lib -lSDLmain -lSDL -lSDL_ttf -lSDL_image -lSDL_draw -lSDL_phelma
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDLmain.a when searching for -lSDLmain
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDL.so when searching for -lSDL
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDL.a when searching for -lSDL
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDL_ttf.so when searching for -lSDL_ttf
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDL_ttf.a when searching for -lSDL_ttf
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDL_image.so when searching for -lSDL_image
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDL_image.a when searching for -lSDL_image
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDL_draw.so when searching for -lSDL_draw
/usr/bin/ld: skipping incompatible /usr/include/2011/lib/libSDL_draw.a when searching for -lSDL_draw
/usr/bin/ld: cannot find -lSDL_draw
collect2: ld returned 1 exit status
make: *** [demo1] Erreur 1
/makefile/
`
DIRSDL=/usr/include/2011
CFLAGS=-g -O2 -I$(DIRSDL)/include
LDFLAGS=$(LFLMAC) -g -L$(DIRSDL)/lib -L/usr/local/lib -lSDLmain -lSDL -lSDL_ttf -lSDL_image -lSDL_draw -lSDL_phelma
demo1: demo1.o
gcc -o demo1 demo1.o $(LDFLAGS)
demo1.o : demo1.c
gcc -c $(CFLAGS) demo1.c
`
skipping incompatible linker message means that the library is incompatible with the binary currently being linked. E.g. you are linking a 64-bit binary with 32-bit libraries, or vice versa.
Try invoking:
file demo1.o
file /usr/include/2011/lib/libSDLmain.a
from the shell to see what architectures these files are for.

Resources