CUDD Binary Decision Trees. Linking to libcudd.a - c

Does anyone on this community have experience with compiling linking the CUDD package for manipulating BDDs? Seems like a great resource if I can only compile something simple... Getting a lot of following.
I am a novice with C, mainly Py guy, so any help would be highly appreciated. (I've tried using tulip-dd in Py, but that is a limited experience). Thanks in advance.
[glarangeira#login1 cudd3]$ gcc basicDD.c
/tmp/cc5v0zuv.o: In function `main':
basicDD.c:(.text+0x2a): undefined reference to `Cudd_Init'
basicDD.c:(.text+0x3a): undefined reference to `Cudd_bddNewVar'
basicDD.c:(.text+0x4a): undefined reference to `Cudd_Ref'
basicDD.c:(.text+0x56): undefined reference to `Cudd_Quit'
collect2: error: ld returned 1 exit status
[glarangeira#login1 cudd3]$ gcc basicDD.c /gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a -o bdd
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAPI.o): In function `Cudd_ExpectedUsedSlots':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAPI.c:1835: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAPI.c:1844: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAPI.c:1850: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddCache.o): In function `cuddCacheProfile':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddCache.c:816: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_CountMinterm':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_LdblCountMinterm':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:729: undefined reference to `powl'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_CountMinterm':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-epd.o): In function `EpdNormalizeDecimal':
/gpfs/software/dd/cudd-3.0.0/epd/epd.c:834: undefined reference to `pow'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-epd.o):/gpfs/software/dd/cudd-3.0.0/epd/epd.c:834: more undefined references to `pow' follow
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `siftBackwardProb':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `cuddAnnealing':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:229: undefined reference to `log'
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:229: undefined reference to `log'
/gpfs/software/dd/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `siftBackwardProb':
/gpfs/software/dd/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
collect2: error: ld returned 1 exit status

Related

"undefined reference" when trying to use lp_solve in C/C++ on Linux

I'm new to linear programming and C. I am trying to use the lp_solve library to solve a linear equation. The problem is I can't get the demo code to work.
As described in the documentation, I downloaded lp_solve_5.5_dev.gz to my Linux machine. I extracted the files into the same folder as my code and tried to compile:
~/Desktop/Code/CA$ cc -o demo demo.c
/tmp/ccpeN8ZV.o: In function `demo':
demo.c:(.text+0x31): undefined reference to `make_lp'
demo.c:(.text+0x62): undefined reference to `set_col_name'
demo.c:(.text+0x7d): undefined reference to `set_col_name'
demo.c:(.text+0xcf): undefined reference to `set_add_rowmode'
demo.c:(.text+0x150): undefined reference to `add_constraintex'
demo.c:(.text+0x1e6): undefined reference to `add_constraintex'
demo.c:(.text+0x274): undefined reference to `add_constraintex'
demo.c:(.text+0x29c): undefined reference to `set_add_rowmode'
demo.c:(.text+0x30b): undefined reference to `set_obj_fnex'
demo.c:(.text+0x327): undefined reference to `set_maxim'
demo.c:(.text+0x33b): undefined reference to `write_LP'
demo.c:(.text+0x34e): undefined reference to `set_verbose'
demo.c:(.text+0x359): undefined reference to `solve'
demo.c:(.text+0x383): undefined reference to `get_objective'
demo.c:(.text+0x3a6): undefined reference to `get_variables'
demo.c:(.text+0x3d2): undefined reference to `get_col_name'
demo.c:(.text+0x429): undefined reference to `delete_lp'
collect2: ld returned 1 exit status
When I add liblpsolve55.a to the command I get the following errors:
~/Desktop/Code/CA$ cc -o demo demo.c liblpsolve55.a
liblpsolve55.a(lp_lib.o): In function `scaled_floor':
lp_lib.c:(.text+0x6923): undefined reference to `floor'
liblpsolve55.a(lp_lib.o): In function `scaled_ceil':
lp_lib.c:(.text+0x6f03): undefined reference to `ceil'
liblpsolve55.a(lp_lib.o): In function `set_XLI':
lp_lib.c:(.text+0x7aa2): undefined reference to `dlclose'
lp_lib.c:(.text+0x7bb3): undefined reference to `dlopen'
lp_lib.c:(.text+0x7bd1): undefined reference to `dlsym'
lp_lib.c:(.text+0x7d8a): undefined reference to `dlsym'
lp_lib.c:(.text+0x7da6): undefined reference to `dlsym'
lp_lib.c:(.text+0x7dc2): undefined reference to `dlsym'
liblpsolve55.a(lp_lib.o): In function `set_BFP':
lp_lib.c:(.text+0x7eb4): undefined reference to `dlclose'
lp_lib.c:(.text+0x7fc3): undefined reference to `dlopen'
lp_lib.c:(.text+0x7fe1): undefined reference to `dlsym'
lp_lib.c:(.text+0x831a): undefined reference to `dlsym'
lp_lib.c:(.text+0x8336): undefined reference to `dlsym'
lp_lib.c:(.text+0x8352): undefined reference to `dlsym'
lp_lib.c:(.text+0x836e): undefined reference to `dlsym'
liblpsolve55.a(lp_lib.o):lp_lib.c:(.text+0x838a): more undefined references to `dlsym' follow
................
I understand that the lp_solve libraries are not loaded in my code. Can you please tell me how I can properly link the lp_solve libraries?
You're just missing some compiler flags to include the proper libraries. As danielko said, a quick google search on the missing libraries brings up some suggestions. E.g.
Linux c++ error: undefined reference to 'dlopen'
http://sourceforge.net/p/dev-cpp/discussion/48211/thread/3bd8b8a1
These suggest your compilation should be something more like:
cc -o demo demo.c -ldl -llpsolve55
and the lpsolve documentation suggests a command that includes the project directory such as:
cc -I/lp_solve_5.5 -I/lp_solve_5.5/bfp -I/lp_solve_5.5/bfp/bfp_etaPFI -I/lp_solve_5.5/colamd $src -o MyExe.exe -lm -ldl

Undefined references when compiling SDL project with MingW (NOT WinMain error)

I've been going a bit crazy trying to figure out the issue here. My project builds fine on Fedora with it's native gcc and pkg-config flags but when cross-compiling or using MingW on Windows it gives me undefined references. The oddest thing was, I remember getting it to compile once or twice on Windows but I have no idea how. As far as I know, all the libraries are accessible, so I can't figure out what's wrong.
With this input:
mingw32-gcc -std=c99 -g -LC:/MinGW/lib -mwindows -lSDL -lSDLmain -lfreetype -lmingw32 -lglu32 -lopengl32 -o bin/gltris.exe gltris.o graphics.o input.o game.o block.o timer.o text.o
I get this output: (sorry for the weird formatting)
C:/MinGW/lib/libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain#16'
gltris.o: In function `gltris_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/gltris.c:24: undefined reference to `SDL_Init'
gltris.o: In function `SDL_main':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/gltris.c:110: undefined reference to `SDL_Quit'
graphics.o: In function `graphics_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:31: undefined reference to `SDL_SetVideoMode'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:34: undefined reference to `glClearColor#16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:35: undefined reference to `glClear#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:36: undefined reference to `glViewport#16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:38: undefined reference to `glMatrixMode#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:39: undefined reference to `glLoadIdentity#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:40: undefined reference to `glDisable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:41: undefined reference to `glBlendFunc#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:42: undefined reference to `glPixelStorei#8'
graphics.o: In function `graphics_begin_frame':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:50: undefined reference to `glMatrixMode#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:51: undefined reference to `glLoadIdentity#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:52: undefined reference to `glClear#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:54: undefined reference to `gluOrtho2D#32'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:56: undefined reference to `glMatrixMode#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:57: undefined reference to `glLoadIdentity#0'
graphics.o: In function `graphics_end_frame':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:62: undefined reference to `SDL_GL_SwapBuffers'
graphics.o: In function `graphics_render_block':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:68: undefined reference to `glPushMatrix#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:70: undefined reference to `glTranslatef#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:71: undefined reference to `glScalef#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:74: undefined reference to `glColor4ub#16'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:76: undefined reference to `glColor3ubv#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:78: undefined reference to `glEnable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:81: undefined reference to `glBegin#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:82: undefined reference to `glVertex2i#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:83: undefined reference to `glVertex2i#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:84: undefined reference to `glVertex2i#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:85: undefined reference to `glVertex2i#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:86: undefined reference to `glEnd#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:88: undefined reference to `glDisable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:90: undefined reference to `glPopMatrix#0'
graphics.o: In function `render_textured_quad':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:165: undefined reference to `glPushMatrix#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:167: undefined reference to `glEnable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:168: undefined reference to `glEnable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:169: undefined reference to `glBindTexture#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:171: undefined reference to `glTranslatef#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:173: undefined reference to `glBegin#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:175: undefined reference to `glTexCoord2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:176: undefined reference to `glVertex2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:178: undefined reference to `glTexCoord2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:179: undefined reference to `glVertex2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:181: undefined reference to `glTexCoord2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:182: undefined reference to `glVertex2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:184: undefined reference to `glTexCoord2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:185: undefined reference to `glVertex2f#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:187: undefined reference to `glEnd#0'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:189: undefined reference to `glDisable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:190: undefined reference to `glDisable#4'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:192: undefined reference to `glPopMatrix#0'
graphics.o: In function `surface_to_texture':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:212: undefined reference to `glGenTextures#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:213: undefined reference to `glBindTexture#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:214: undefined reference to `glTexParameteri#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:215: undefined reference to `glTexParameteri#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:216: undefined reference to `glTexImage2D#36'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/graphics.c:221: undefined reference to `SDL_FreeSurface'
input.o: In function `handle_input':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/input.c:13: undefined reference to `SDL_PollEvent'
timer.o: In function `add_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:20: undefined reference to `SDL_GetTicks'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:36: undefined reference to `SDL_GetTicks'
timer.o: In function `do_timers':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:65: undefined reference to `SDL_GetTicks'
timer.o: In function `pause_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:84: undefined reference to `SDL_GetTicks'
timer.o: In function `resume_timer':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:90: undefined reference to `SDL_GetTicks'
timer.o:C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/timer.c:98: more undefined references to `SDL_GetTicks' follow
text.o: In function `text_init':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:24: undefined reference to `_imp__FT_Init_FreeType'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:28: undefined reference to `_imp__FT_New_Face'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:32: undefined reference to `_imp__FT_Set_Char_Size'
text.o: In function `text_gen_texture':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:70: undefined reference to `glGenTextures#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:71: undefined reference to `glBindTexture#8'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:72: undefined reference to `glTexParameteri#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:73: undefined reference to `glTexParameteri#12'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:77: undefined reference to `glTexImage2D#36'
text.o: In function `text_print':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:92: undefined reference to `_imp__FT_Set_Char_Size'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:97: undefined reference to `_imp__FT_Load_Char'
text.o: In function `get_text_size':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:115: undefined reference to `_imp__FT_Set_Char_Size'
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:119: undefined reference to `_imp__FT_Load_Char'
text.o: In function `print_game_info':
C:\MinGW\msys\1.0\home\Max\gltris-unstable/src/text.c:138: undefined reference to `glColor3f#12'
collect2.exe: error: ld returned 1 exit status
EDIT:I got it to build by compiling and linking in one go, with the linker flags "-lmingw32 -lopengl32 -lSDLmain -lSDL -lfreetype -mwindows"
It seems like your compiler cannot find libSDL.a and other library files. Check if libSDL.a is present in C:/MinGW/lib. You will need a libSDL.a that is specifically made for mingw.
Also, try compiling a simple "Hello World" SDL program. That will make it easier to find what the error is.

Compilation error in GCC on Linux

I am trying to compile my code for GnuTLS, but on compiling it gives the following errors.
I have checked gnutls.h is present on my system in /usr/include/gnutls/.
What else can be the cause?
gcc -o tls.o tls.c
/tmp/ccfyZ1Bd.o: In function `main':
tls.c:(.text+0x1c): undefined reference to `gnutls_global_init'
tls.c:(.text+0x28): undefined reference to `gnutls_anon_allocate_client_credentials'
tls.c:(.text+0x3c): undefined reference to `gnutls_init'
tls.c:(.text+0x58): undefined reference to `gnutls_priority_set_direct'
tls.c:(.text+0x74): undefined reference to `gnutls_credentials_set'
tls.c:(.text+0x79): undefined reference to `tcp_connect'
tls.c:(.text+0x91): undefined reference to `gnutls_transport_set_ptr'
tls.c:(.text+0x9d): undefined reference to `gnutls_handshake'
tls.c:(.text+0xdc): undefined reference to `gnutls_perror'
tls.c:(.text+0x109): undefined reference to `gnutls_record_send'
tls.c:(.text+0x125): undefined reference to `gnutls_record_recv'
tls.c:(.text+0x154): undefined reference to `gnutls_strerror'
tls.c:(.text+0x1e6): undefined reference to `gnutls_bye'
tls.c:(.text+0x1f2): undefined reference to `tcp_close'
tls.c:(.text+0x1fe): undefined reference to `gnutls_deinit'
tls.c:(.text+0x20a): undefined reference to `gnutls_anon_free_client_credentials'
tls.c:(.text+0x20f): undefined reference to `gnutls_global_deinit'
collect2: ld returned 1 exit status
This is a linking error. You need to include some library with the -l flag. Taking a wild guess without knowing your setup, I would try -lgnutls

error in SD card program

i run sd card program in linux but i found following error....but i include header file also
anish#ubuntu:~/Desktop/testing/sd card$ gcc -o sdcard sdcard.c
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/tmp/ccVMCgzn.o: In function `SDCardInit':
sdcard.c:(.text+0x23): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x4d): undefined reference to `SPI1Send'
sdcard.c:(.text+0x8b): undefined reference to `SPI1Byte'
sdcard.c:(.text+0xb2): undefined reference to `SPI1Send'
sdcard.c:(.text+0xfd): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x102): undefined reference to `CRC16Bit_GenTable'
/tmp/ccVMCgzn.o: In function `SDResponseMatch':
sdcard.c:(.text+0x128): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDResponseDontMatch':
sdcard.c:(.text+0x162): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDWriteBlock':
sdcard.c:(.text+0x1db): undefined reference to `CRC_7Bit'
sdcard.c:(.text+0x202): undefined reference to `SPI1Send'
sdcard.c:(.text+0x23b): undefined reference to `CRC_16Bit'
sdcard.c:(.text+0x24a): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x25d): undefined reference to `SPI1Send'
sdcard.c:(.text+0x26b): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x27b): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x287): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x2f7): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDReadBlockPart':
sdcard.c:(.text+0x35e): undefined reference to `CRC_7Bit'
sdcard.c:(.text+0x388): undefined reference to `SPI1Send'
sdcard.c:(.text+0x3f0): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x3ff): undefined reference to `CRC_16Bit_AddByte'
sdcard.c:(.text+0x41c): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x43b): undefined reference to `CRC_16Bit_AddByte'
sdcard.c:(.text+0x463): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x472): undefined reference to `CRC_16Bit_AddByte'
sdcard.c:(.text+0x48e): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x4a0): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x4d6): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDWriteBlockHead':
sdcard.c:(.text+0x53c): undefined reference to `CRC_7Bit'
sdcard.c:(.text+0x563): undefined reference to `SPI1Send'
sdcard.c:(.text+0x59b): undefined reference to `CRC_16Bit'
s dcard.c:(.text+0x5aa): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x5ca): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x5f0): undefined reference to `CRC_16Bit_AddByte'
sdcard.c:(.text+0x5ff): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x616): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x626): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x632): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x6a2): undefined reference to `SPI1Byte'
/tmp/ccVMCgzn.o: In function `SDWriteMultiBlock':
sdcard.c:(.text+0x702): undefined reference to `CRC_7Bit'
sdcard.c:(.text+0x729): undefined reference to `SPI1Send'
sdcard.c:(.text+0x76e): undefined reference to `CRC_16Bit'
sdcard.c:(.text+0x77d): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x790): undefined reference to `SPI1Send'
sdcard.c:(.text+0x7a5): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x7b5): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x7c1): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x7fa): undefined reference to `SPI1Byte'
sdcard.c:(.text+0x847): undefined reference to `SPI1Byte'
Looks like to me your forgot to link a couple of libraries.
or if you want to generate an object file to link it afterwards, this would be better
gcc -o sdcard.o sdcard.c
crt1.o is the C Runtime. It specifies where to start the program and few other things. Execution starts at _start symbol and then jumps to the main defined in the program. So from error
In function `_start':
(.text+0x18): undefined reference to `main'
my guess is that you may have misspelled your main function, may be you have named it Main or something else.
For other errors, you will need to link with the library that provides these functions or, if you are using functions in other source files, you will need to compile them too then link all of these files together.

Error Deflate And Inflate With zLib

I'm trying to compile the zpipe.c example in my Linux(Ubuntu 8.04) with gcc, but I'm getting some errors, take a look:
[ubuntu#eeepc:~/Desktop] gcc zpipe.c
/tmp/ccczEQxz.o: In function `def':
zpipe.c:(.text+0x65): undefined reference to `deflateInit_'
zpipe.c:(.text+0xd3): undefined reference to `deflateEnd'
zpipe.c:(.text+0x150): undefined reference to `deflate'
zpipe.c:(.text+0x1e8): undefined reference to `deflateEnd'
zpipe.c:(.text+0x27b): undefined reference to `deflateEnd'
/tmp/ccczEQxz.o: In function `inf':
zpipe.c:(.text+0x314): undefined reference to `inflateInit_'
zpipe.c:(.text+0x382): undefined reference to `inflateEnd'
zpipe.c:(.text+0x3d7): undefined reference to `inflate'
zpipe.c:(.text+0x44b): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4c1): undefined reference to `inflateEnd'
zpipe.c:(.text+0x4f6): undefined reference to `inflateEnd'
collect2: ld returned 1 exit status
[ubuntu#eeepc:~/Desktop]
Remember that I've installed zLib-dev correctly, but why i'm getting this errors?
You need to link it with the zlib library as well. Just add -lz to near end of your command line.

Resources