digego / extempore

A cyber-physical programming environment
1.4k stars 127 forks source link

Build error during "libs/external/stb_image.xtm" compilation #292

Closed jpt4 closed 6 years ago

jpt4 commented 7 years ago

Following the Extempore installation instructions for Linux, using Arch with kernel version 4.8.12-1, everything appears successful until the error in the issue title.

$ make install

[... successful compilation elided ...]

------------- Extempore -------------- 
Andrew Sorensen (c) 2010-2016
andrew@moso.com.au, @digego

ARCH           : x86_64-unknown-linux-gnu
CPU            : ivybridge
ATTRS          : -sse4a,-avx512bw,+cx16,-tbm,-adx,-fma4,-avx512vl,-prfchw,-bmi2,-avx512pf,+fsgsbase,+avx,-avx512cd,-rtm,+popcnt,-fma,-bmi,+aes,+rdrnd,+sse4.1,+sse4.2,-avx2,-avx512er,+sse,-lzcnt,+pclmul,-avx512f,+f16c,+ssse3,+mmx,+cmov,-xop,-rdseed,-movbe,-hle,-sha,+sse2,+sse3,-avx512dq
LLVM           : 3.7.0 MCJIT
---------------------------------------

Starting utility process
Trying to connect to 'localhost' on port 17078
New Client Connection 
Successfully connected to remote process

Starting primary process
Trying to connect to 'localhost' on port 17079
New Client Connection 
Successfully connected to remote process

Evaluating expression: (impc:aot:compile-xtm-file "libs/external/stb_image.xtm" #t #t)

Started compiling: "libs/external/stb_image.xtm"

Loading xtmbase library... done in 0.000000 seconds
sys:load notification base already loaded 
Error: could not find libstb_image dynamic library

I tried the instructions in the commentary in https://github.com/digego/extempore/blob/master/libs/external/stb_image.xtm

;; grab the source from github, then
;; - rename stb_image*.h to stb_image*.c
;; - clang -dynamiclib -o libstb_image.dylib stb_image.c stb_image_resize.c stb_image_write.c

and attempted to run clang on the appropriate renamed files from https://github.com/nothings/stb, but received the following error:

/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)

With -v:

$ clang -dynamic -o libstb_image.dylib stb_image.c stb_image_resize.c stb_image_write.c -v
clang version 3.9.0 (tags/RELEASE_390/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/clang-3.9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name stb
_image.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -ta
rget-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/bin/../lib/clang/3.9.0 -internal-isystem /usr/local/include -internal-isystem /us
r/bin/../lib/clang/3.9.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/jpt4/code/stb -ferror-
limit 19 -fmessage-length 159 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/stb_image-049223.o -x c stb_image.c
clang -cc1 version 3.9.0 based upon LLVM 3.9.0 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/bin/../lib/clang/3.9.0/include
 /usr/include   
End of search list.
 "/usr/bin/clang-3.9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name stb
_image_resize.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-ar
ray -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/bin/../lib/clang/3.9.0 -internal-isystem /usr/local/include -internal-isys
tem /usr/bin/../lib/clang/3.9.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/jpt4/code/stb -
ferror-limit 19 -fmessage-length 159 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/stb_image_resize-a840df.o -x c stb_image_resize.c
clang -cc1 version 3.9.0 based upon LLVM 3.9.0 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/bin/../lib/clang/3.9.0/include
 /usr/include   
End of search list.
 "/usr/bin/clang-3.9" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name stb
_image_write.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-arr
ay -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/bin/../lib/clang/3.9.0 -internal-isystem /usr/local/include -internal-isyst
em /usr/bin/../lib/clang/3.9.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/jpt4/code/stb -f
error-limit 19 -fmessage-length 159 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/stb_image_write-86d0d8.o -x c stb_image_write.c
clang -cc1 version 3.9.0 based upon LLVM 3.9.0 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/bin/../lib/clang/3.9.0/include
 /usr/include   
End of search list.
 "/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o libstb_image.dylib /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/.
./../../../lib64/crt1.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/crtbegin.o -L/
usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/l
ib/../lib64 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib /tmp/stb_image-049223.o /tmp/stb_image_resize-a840df
.o /tmp/stb_image_write-86d0d8.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib64/gcc/x86_64-pc-linux-gn
u/6.2.1/crtend.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib64/crtn.o
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)

main doesn't exist in any of the source files, but my clang/gcc knowledge fails me at this point, as does my searching for similar problems. Any assistance or pointers to solutions would be greatly appreciated.

benswift commented 7 years ago

The stb_image shared library should be built automatically (the make target is called stb_image - you could re-try building it to check). If it worked properly, then libstb_image.so will end up in extempore/libs/platform-shlibs, which is the first place that the bind-dylib call in libs/external/stb_image.xtm should look. This is what's failing.

So, that might help you figure out where exactly it's going wrong. I'm afraid that I'm just about to go on holidays, so I won't be able to help, but you should ask on the mailing list.

Good luck!

digego commented 7 years ago

can I close this?