MonetDB client compilation - c

I'm a beginner in the Database community. I have been trying to interface with MonetDB using C/C++ MAPI. I have installed MonetDB on my Ubuntu 14.04 LTS machine and when I try to compile a sample program from here, I get the following error:
$ gcc test.c -I /usr/include/monetdb -lmapi
test.c:(.text+0x29): undefined reference to mapi_explain_query'
test.c:(.text+0x35): undefined reference tomapi_result_error'
test.c:(.text+0x50): undefined reference to mapi_explain_result'
test.c:(.text+0x5c): undefined reference tomapi_next_result'
test.c:(.text+0x6d): undefined reference to mapi_close_handle'
test.c:(.text+0x79): undefined reference tomapi_destroy'
test.c:(.text+0x98): undefined reference to mapi_explain'
test.c:(.text+0xa4): undefined reference tomapi_destroy'
/tmp/cctyQopc.o: In function query':
test.c:(.text+0xf9): undefined reference tomapi_query'
test.c:(.text+0x110): undefined reference to mapi_error'
/tmp/cctyQopc.o: In functionupdate':
test.c:(.text+0x160): undefined reference to mapi_close_handle'
/tmp/cctyQopc.o: In functionmain':
test.c:(.text+0x1b6): undefined reference to mapi_connect'
test.c:(.text+0x1c6): undefined reference tomapi_error'
test.c:(.text+0x238): undefined reference to mapi_fetch_field'
test.c:(.text+0x24d): undefined reference tomapi_fetch_field'
test.c:(.text+0x277): undefined reference to mapi_fetch_row'
test.c:(.text+0x287): undefined reference tomapi_close_handle'
test.c:(.text+0x293): undefined reference to `mapi_destroy'
collect2: error: ld returned 1 exit status
This question has previously been asked here and the answer did not solve the problem (although the answer was accepted, I'm not sure why). Any help/directions would be great!

On Ubuntu 18.04 using:
pkg-config --libs monetdb-mapi and pkg-config --cflags monetdb-mapi
Won't work because Ubuntu doesn't have a bzip2.pc:
Here how it worked:
gcc main.c -I /usr/include/monetdb -lmapi -lssl -lcrypto -lstream -lcurl -llzma -lbz2

Related

mingw+libarchive: cross compiling linker error

I'm trying to cross compile a tiny program under Linux for win32. It uses libarchive, which is available in for mingw on my fedora 23 installation (all installed through dnf), but I get lots of linker errors.
Source: https://github.com/panzi/save_the_zazus
Compiler/linker output:
panzi#panzi save_the_zazus [master*]$ mkdir -p package/img
panzi#panzi save_the_zazus [master*]$ touch package/img/atlas0.png package/img/atlas1.png package/img/atlas2.png
panzi#panzi save_the_zazus [master*]$ make TARGET=win32 setup
mkdir -p build/win32 build/src
panzi#panzi save_the_zazus [master*]$ make TARGET=win32
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -Wall -Werror -Wextra -std=gnu11 -Ibuild/src -O2 -c src/save_the_zazus.c -o build/win32/save_the_zazus.o
xxd -i package/img/atlas0.png > build/src/package_img_atlas0_png.c
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -Wall -Werror -Wextra -std=gnu11 -Ibuild/src -O2 -c build/src/package_img_atlas0_png.c -o build/win32/package_img_atlas0_png.o
xxd -i package/img/atlas1.png > build/src/package_img_atlas1_png.c
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -Wall -Werror -Wextra -std=gnu11 -Ibuild/src -O2 -c build/src/package_img_atlas1_png.c -o build/win32/package_img_atlas1_png.o
xxd -i package/img/atlas2.png > build/src/package_img_atlas2_png.c
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -Wall -Werror -Wextra -std=gnu11 -Ibuild/src -O2 -c build/src/package_img_atlas2_png.c -o build/win32/package_img_atlas2_png.o
i686-w64-mingw32-gcc -m32 -DLIBARCHIVE_STATIC -static -larchive build/win32/save_the_zazus.o build/win32/package_img_atlas0_png.o build/win32/package_img_atlas1_png.o build/win32/package_img_atlas2_png.o -o build/win32/save_the_zazus.exe
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x301): undefined reference to `archive_read_new'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x31d): undefined reference to `archive_read_support_filter_all'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x3cd): undefined reference to `archive_entry_free'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x3df): undefined reference to `archive_read_free'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x3ef): undefined reference to `archive_write_free'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x426): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x462): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x4a1): undefined reference to `archive_read_support_format_all'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x538): undefined reference to `archive_read_open_filename'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x545): undefined reference to `archive_write_new'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x557): undefined reference to `archive_write_set_format_zip'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x56b): undefined reference to `archive_write_set_options'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x581): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x5c9): undefined reference to `archive_write_open_filename'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x5d9): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x61e): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x67a): undefined reference to `archive_entry_new2'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x6ba): undefined reference to `archive_read_next_header2'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x6d0): undefined reference to `archive_entry_pathname'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x727): undefined reference to `archive_entry_new2'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x73d): undefined reference to `archive_entry_copy_pathname'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x74b): undefined reference to `archive_entry_perm'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x75a): undefined reference to `archive_entry_set_perm'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x762): undefined reference to `archive_entry_filetype'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x771): undefined reference to `archive_entry_set_filetype'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x77f): undefined reference to `archive_entry_mode'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x78e): undefined reference to `archive_entry_set_mode'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7a5): undefined reference to `archive_entry_set_size'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7b3): undefined reference to `archive_entry_uid'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7c3): undefined reference to `archive_entry_set_uid'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7d1): undefined reference to `archive_entry_gid'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7e1): undefined reference to `archive_entry_set_gid'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x7ef): undefined reference to `archive_entry_mtime_nsec'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x803): undefined reference to `archive_entry_mtime'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x819): undefined reference to `archive_entry_set_mtime'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x82b): undefined reference to `archive_write_header'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x83b): undefined reference to `archive_entry_free'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x854): undefined reference to `archive_write_data'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x870): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x904): undefined reference to `archive_write_header'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x91a): undefined reference to `archive_entry_size'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x948): undefined reference to `archive_read_data'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x96c): undefined reference to `archive_write_data'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x988): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0x9dd): undefined reference to `archive_write_add_filter_none'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0xa13): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0xa47): undefined reference to `archive_entry_free'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0xa8e): undefined reference to `archive_error_string'
build/win32/save_the_zazus.o:save_the_zazus.c:(.text.startup+0xad6): undefined reference to `archive_error_string'
collect2: error: ld returned 1 exit status
Makefile:82: recipe for target 'build/win32/save_the_zazus.exe' failed
make: *** [build/win32/save_the_zazus.exe] Error 1
For this single source file program I just wrote a simple Makefile. The png files aren't in the repo (yet), so just create empty files for them if you try to compile. I tried dynamic and static linking (would prefer static so all I need to do is to pass on a .exe file). For this output I used -static -larchive and it doesn't complain about any missing libraries, but I get all those undefined references.
Add -static -larchive to the end of your command line and try again. The linker isn't getting the library to link against. I've found it needs to be last on the command line.

Gstream ARM cross compilation

I want to write an embedded GStreamer application for an ARM processor. I have a Freescale enviroment,which contains installed gstream-0.10 & cross-compiler toolchain.
I took a first Hello World application from GStream manual and tried to compile it by
arm-poky-linux-gnueabi-gcc video_1.c -o basic-tutorial-1 pkg-config --cflags --libs gstreamer-0.10
My gstreamer-0.10.pc consists:
prefix=/home/.../build_mx6q/tmp/sysroots/varsommx6q/usr
exec_prefix=/usr
libdir=/home/.../build_mx6q/tmp/sysroots/varsommx6q/usr/lib
includedir=/home/.../build_mx6q/tmp/sysroots/varsommx6q/usr/include/gstreamer-0.10
toolsdir=${exec_prefix}/bin
pluginsdir=/usr/lib/gstreamer-0.10
datarootdir=${prefix}/share
datadir=${datarootdir}
girdir=${datadir}/gir-1.0
typelibdir=${libdir}/girepository-1.0
Name: GStreamer
Description: Streaming media framework
Requires: glib-2.0, gobject-2.0, gmodule-no-export-2.0, gthread-2.0, libxml-2.0
Version: 0.10.36
Libs: -L${libdir} -lgstreamer-0.10
Cflags: -I${includedir}*
Compilation result:
warning: libffi.so.6, needed by /.../usr/lib/libgstreamer-0.10.so, not found (try using -rpath or -rpath-link)
warning: libz.so.1, needed by /.../usr/lib/libgstreamer-0.10.so, not found (try using -rpath or -rpath-link)
/home/.../usr/lib/libgobject-2.0.so: undefined reference to `ffi_type_pointer'
/home/.../usr/lib/libxml2.so: undefined reference to `inflateEnd'
/home/.../usr/lib/libxml2.so: undefined reference to `gzdirect#ZLIB_1.2.2.3'
/home/.../usr/lib/libxml2.so: undefined reference to `gzclose'
/home/.../usr/lib/libxml2.so: undefined reference to `deflate'
/home/.../usr/lib/libgobject-2.0.so: undefined reference to `ffi_type_float'
/home/.../usr/lib/libxml2.so: undefined reference to `inflateInit2_'
/home/.../usr/lib/libxml2.so: undefined reference to `inflate'
/home/.../usr/lib/libgobject-2.0.so: undefined reference to `ffi_type_void'
/home/.../usr/lib/libxml2.so: undefined reference to `gzwrite'
/home/.../usr/lib/libgobject-2.0.so: undefined reference to `ffi_type_sint64'
/home/.../usr/lib/libxml2.so: undefined reference to `crc32'
/home/.../usr/lib/libxml2.so: undefined reference to `deflateEnd'
...
collect2: error: ld returned 1 exit status
Something went wrong, but I don't understand what and where.
I still need a help.
Thank you.
Try this
arm-poky-linux-gnueabi-gcc video_1.c -o basic-tutorial-1 ` pkg-config --cflags --libs gstreamer-0.10`

Issue with lua51 c-shared library

I am trying to compile a simple example program that depends on a shared library (so) that depends on liblua51.so. My source file is example.c and here is the command I am using to compile it (it is written in C)
cc -Wall -fPIC -ldl -o a.out -I./ste-linux/ste-interface-files/c/ -L./ste-linux/ste-shared-libraries/ example.c -lm -llua51 -lste -lm -ldl
I am getting the following errors:
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `sinh'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `ceil'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `atan2'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `tanh'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `cosh'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `fmod'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `acos'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `sin'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `atan'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `asin'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `exp'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `tan'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `cos'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `log'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `pow'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `log10'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `sqrt'
./ste-linux/ste-shared-libraries//liblua51.so: undefined reference to `floor'
I have read a bunch of other threads on stackoverflow saying adding the -lm flag will fix this, but no matter where I put the -L and -lm -ldl in the command, these undefined references will not go away.
I am trying to compile this lib on ubuntu 12.04 LTS
Help please
The issue was the shared library I was using was built with a different version of GCC. After I downgrade from Ubuntu 11.04 (from 12.04 LTS) it was resolved.

libcurl curl/curl.h No such file or Directory Win xp 32 MinGW

I have been searching for a couple of hours and found several threads with the same problem and tried all their suggestions.
My curl.h is in C:\MinGW\msys\1.0\curl-7.29.0\include\curl and I've included it at compile time but for some reason gcc claims it can't find it:
gcc -o curl.exe curl.c -IC:/MinGW/msys/1.0/local/ -IC:/MinGW/msys/1.0/curl-7.29.0/lib/.libs/ -IC:/MinGW/msys/1.0/curl-7.29.0/include/curl -IC:/MinGW/msys/1.0/OpenSSL-Win32/ -lcurl -lws2_32
and the result:
curl.c:4:32: fatal error: curl/curl.h: No such file or directory
UPDATE: (With the suggestion from H2CO3)
$ gcc -o curl.exe curl.c -IC:/MinGW/msys/1.0/local -IC:/MinGW/msys/1.0/curl-7.29.0/lib/.libs/ -IC:/MinGW/msys/1.0/curl-7.29.0/include/ -IC:/MinGW/msys/1.0/OpenSSL-Win32/include/ -lws2_32
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0xa8): undefined reference to `_imp__curl_global_init'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0xe6): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x124): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x162): undefined reference to `_imp__curl_formadd'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x169): undefined reference to `_imp__curl_easy_init'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x183): undefined reference to `_imp__curl_slist_append'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x1b8): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x211): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x237): undefined reference to `_imp__curl_easy_setopt'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x245): undefined reference to `_imp__curl_easy_perform'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x25e): undefined reference to `_imp__curl_easy_strerror'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x288): undefined reference to `_imp__curl_easy_cleanup'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x296): undefined reference to `_imp__curl_formfree'
C:\DOCUME~1\J10441\LOCALS~1\Temp\ccHP6WWt.o:curl.c:(.text+0x2a4): undefined reference to `_imp__curl_slist_free_all'
collect2: ld returned 1 exit status
If I try to compile with -lcurl it says ..... ld.exe: cannot find -lcurl is this because it can't find the dll?
You're including <curl/curl.h>, and not <curl.h>. So you have to tell the compiler to look for header files in the include directory, and not in include/curl:
gcc -IC:\MinGW\msys\1.0\curl-7.29.0\include etc. etc.
This might be beyond the scope of what you're doing, but, I found it best to install a version of cURL(libcurl) into the MinGW/MSYS environment. After installed, any program can be compiled to use it with the typical <curl/curl.h> and -lcurl conventions since it's installed where GCC would expect it. I documented my process here.

MinGW/libssl Linking Errors

I am porting an application that I developed in Linux to Windows and am having some issues when building the application. After making the necessary code changes, everything compiles fine (and when built as a debug build in Visual Studio, runs without any issues). I need to build this in MinGW, and I'm having linker errors when I try to link it against liboauth, which is also required for my project.
The command and its output are as follows:
gcc application.o service.o util.o json.o api.o -L/usr/local/lib -lcrypto -lssl -lcurl -ljansson -loauth -Wl -o application
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_sign_hmac_sha1_raw':
c:\lib\liboauth-0.9.4\src/hash.c:314: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:314: undefined reference to `HMAC'
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_sign_rsa_sha1':
c:\lib\liboauth-0.9.4\src/hash.c:334: undefined reference to `BIO_new_mem_buf'
c:\lib\liboauth-0.9.4\src/hash.c:335: undefined reference to `PEM_read_bio_PrivateKey'
c:\lib\liboauth-0.9.4\src/hash.c:336: undefined reference to `BIO_free'
c:\lib\liboauth-0.9.4\src/hash.c:343: undefined reference to `EVP_PKEY_size'
c:\lib\liboauth-0.9.4\src/hash.c:346: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:346: undefined reference to `EVP_DigestInit'
c:\lib\liboauth-0.9.4\src/hash.c:347: undefined reference to `EVP_DigestUpdate'
c:\lib\liboauth-0.9.4\src/hash.c:348: undefined reference to `EVP_SignFinal'
c:\lib\liboauth-0.9.4\src/hash.c:352: undefined reference to `CRYPTO_free'
c:\lib\liboauth-0.9.4\src/hash.c:353: undefined reference to `EVP_PKEY_free'
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_verify_rsa_sha1':
c:\lib\liboauth-0.9.4\src/hash.c:367: undefined reference to `BIO_new_mem_buf'
c:\lib\liboauth-0.9.4\src/hash.c:368: undefined reference to `PEM_read_bio_X509'
c:\lib\liboauth-0.9.4\src/hash.c:370: undefined reference to `X509_get_pubkey'
c:\lib\liboauth-0.9.4\src/hash.c:371: undefined reference to `X509_free'
c:\lib\liboauth-0.9.4\src/hash.c:375: undefined reference to `BIO_free'
c:\lib\liboauth-0.9.4\src/hash.c:384: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:384: undefined reference to `EVP_DigestInit'
c:\lib\liboauth-0.9.4\src/hash.c:385: undefined reference to `EVP_DigestUpdate'
c:\lib\liboauth-0.9.4\src/hash.c:386: undefined reference to `EVP_VerifyFinal'
c:\lib\liboauth-0.9.4\src/hash.c:387: undefined reference to `EVP_MD_CTX_cleanup'
c:\lib\liboauth-0.9.4\src/hash.c:388: undefined reference to `EVP_PKEY_free'
c:\lib\liboauth-0.9.4\src/hash.c:373: undefined reference to `PEM_read_bio_PUBKEY'
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_body_hash_file':
c:\lib\liboauth-0.9.4\src/hash.c:405: undefined reference to `EVP_MD_CTX_init'
c:\lib\liboauth-0.9.4\src/hash.c:406: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:406: undefined reference to `EVP_DigestInit'
c:\lib\liboauth-0.9.4\src/hash.c:408: undefined reference to `EVP_DigestUpdate'
c:\lib\liboauth-0.9.4\src/hash.c:412: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:412: undefined reference to `EVP_MD_size'
c:\lib\liboauth-0.9.4\src/hash.c:413: undefined reference to `EVP_DigestFinal'
c:\lib\liboauth-0.9.4\src/hash.c:414: undefined reference to `EVP_MD_CTX_cleanup'
C:/MinGW/msys/1.0/local/lib/liboauth.a(liboauth_la-hash.o): In function `oauth_body_hash_data':
c:\lib\liboauth-0.9.4\src/hash.c:422: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:422: undefined reference to `EVP_MD_size'
c:\lib\liboauth-0.9.4\src/hash.c:423: undefined reference to `EVP_MD_CTX_init'
c:\lib\liboauth-0.9.4\src/hash.c:424: undefined reference to `EVP_sha1'
c:\lib\liboauth-0.9.4\src/hash.c:424: undefined reference to `EVP_DigestInit'
c:\lib\liboauth-0.9.4\src/hash.c:425: undefined reference to `EVP_DigestUpdate'
c:\lib\liboauth-0.9.4\src/hash.c:426: undefined reference to `EVP_DigestFinal'
c:\lib\liboauth-0.9.4\src/hash.c:427: undefined reference to `EVP_MD_CTX_cleanup'
collect2: ld returned 1 exit status
make: *** [montools] Error 1
I have all of the required libraries in the lib path, and for some reason liboauth just cannot find the references to libssl and libcrypto. This all builds fine in Linux. Any ideas?
Update
Based on responses, I have updated my linker command so as to link the libraries in a different order. My new command is as follows:
gcc -o application application.o service.o util.o json.o api.o -Lc:/mingw/msys/1.0/local/lib -loauth -ljansson -lcurl -lssl -lcrypto
This fixes this previous problem and presents a new set of linker errors:
gcc -o application application.o service.o util.o json.o api.o -Lc:/mingw/msys/1.0/local/lib -loauth -ljansson -lcurl -lssl -lcrypto
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xee0): undefined reference to `CreateDCA#16'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xeef): undefined reference to `CreateCompatibleDC#4'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf08): undefined reference to `GetDeviceCaps#8'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf23): undefined reference to `GetDeviceCaps#8'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf44): undefined reference to `CreateCompatibleBitmap#12'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf5b): undefined reference to `SelectObject#8'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0xf7e): undefined reference to `GetObjectA#12'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x1024): undefined reference to `BitBlt#36'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x103b): undefined reference to `GetBitmapBits#12'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x10b0): undefined reference to `SelectObject#8'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x10bb): undefined reference to `DeleteObject#4'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x10c8): undefined reference to `DeleteDC#4'
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../libcrypto.a(rand_win.o):rand_win.c:(.text+0x10d5): undefined reference to `DeleteDC#4'
collect2: ld returned 1 exit status
make: *** [montools] Error 1
A quick google search returned that I should also link in the gdi32 library (for purposes unrelated to my tasks. The final command for the linker is then as follows:
gcc -o application application.o service.o util.o json.o api.o -Lc:/mingw/msys/1.0/local/lib -loauth -ljansson -lcurl -lssl -lcrypto -lgdi32
Try this:
gcc -o application application.o service.o util.o json.o api.o -Lc:/mingw/msys/1.0/local/lib -loauth -ljansson -lcurl -lssl -lcrypto

Resources