I have encountered a strange problem while setting up my PC (Win 7 Ultimate 64 CPU AMD/ GPU AMD) for our current Projekt which requires OpenCL.
I have MSYS so I am working on mingw with gcc. I am desperately trying to compile a simple piece of work called openclexample.
Note: the directory containing "openclexample" does contain a lib folder including the reimplemented libOpenCL.a, OpenCL.lib and OVDecode64.lib.
OpenCL.dll in in windows/system32
now when I try to compile using
$ gcc -std=c99 -lOpenCL -o openclexample.exe openclexample.c
all I get is a bunch of undefined reference errors in ALL funktions listet within the OpenCL.def
Ani#ANYONE /d/StuPro/OpenCLtests
$ gcc -std=c99 -lOpenCL -o openclexample.exe openclexample.c
openclexample.c: In function 'main':
openclexample.c:214:3: warning: implicit declaration of function 'srandom' [-Wim
plicit-function-declaration]
openclexample.c:217:7: warning: implicit declaration of function 'random' [-Wimp
licit-function-declaration]
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x35): undefin
ed reference to `clGetDeviceIDs#24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x8c): undefin
ed reference to `clCreateContext#24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0xd9): undefin
ed reference to `clCreateCommandQueue#20'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x127): undefi
ned reference to `clCreateProgramWithSource#20'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x17f): undefi
ned reference to `clBuildProgram#24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x1be): undefi
ned reference to `clCreateKernel#12'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x22c): undefi
ned reference to `clCreateBuffer#24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x264): undefi
ned reference to `clCreateBuffer#24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x29c): undefi
ned reference to `clCreateBuffer#24'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x2f1): undefi
ned reference to `clSetKernelArg#16'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x319): undefi
ned reference to `clSetKernelArg#16'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x346): undefi
ned reference to `clSetKernelArg#16'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x373): undefi
ned reference to `clSetKernelArg#16'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x3e5): undefi
ned reference to `clEnqueueWriteBuffer#36'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x433): undefi
ned reference to `clEnqueueWriteBuffer#36'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x4b2): undefi
ned reference to `clEnqueueNDRangeKernel#36'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x51f): undefi
ned reference to `clEnqueueReadBuffer#36'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x54f): undefi
ned reference to `clFinish#4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x55d): undefi
ned reference to `clReleaseMemObject#4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x56b): undefi
ned reference to `clReleaseMemObject#4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x579): undefi
ned reference to `clReleaseMemObject#4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x587): undefi
ned reference to `clReleaseKernel#4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x595): undefi
ned reference to `clReleaseProgram#4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x5a3): undefi
ned reference to `clReleaseCommandQueue#4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x5b1): undefi
ned reference to `clReleaseContext#4'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x72a): undefi
ned reference to `srandom'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x75f): undefi
ned reference to `random'
C:\Users\Ani\AppData\Local\Temp\ccOLx5XT.o:openclexample.c:(.text+0x7a4): undefi
ned reference to `random'
collect2: ld returned 1 exit status
I have read hundreds of threads but didn't find the solution, some suggested link it with -static, or enter the path where your lib files are... didn't work either.
I'd be really grateful if anyone else had an idea!
The arguments to the linker have to be in the right order. You can see that the library search path (-L) is OK because the linker doesn't whine about not finding libraries. The symbols are undefined because -lOpenCL was mentioned before the object/source file that is using it.
$ gcc -std=c99 -o openclexample.exe openclexample.c -lOpenCL
Related
I'm working on ubuntu 14.04 LTS and am working on a shading example program. I have the following makefile:
CC=gcc
CFLAGS=-Wall -I/usr/X11R6/include
LDFLAGS=-pthread -L/usr/X11R6/lib -lm -lGL -lglut
OBJS=main.o scene.o shader.o
glsl_lighting: $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o glsl_lighting
clean:
rm -f glsl_lighting
rm -f $(OBJS)
main.o: main.c
scene.o: scene.c
shader.o: shader.c
With the first few lines of the main file being:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "opengl.h"
This gave the following error:
gcc -pthread -L/usr/X11R6/lib -lm -lGL -lglut main.o scene.o shader.o -o glsl_lighting
main.o: In function `handleKeyPress':
main.c:(.text+0x27): undefined reference to `glutDestroyWindow'
main.o: In function `setPerspective':
main.c:(.text+0x65): undefined reference to `tanf'
main.c:(.text+0x144): undefined reference to `glMultMatrixf'
main.o: In function `main':
main.c:(.text+0x168): undefined reference to `glutInit'
main.c:(.text+0x172): undefined reference to `glutInitDisplayMode'
main.c:(.text+0x185): undefined reference to `glutInitWindowSize'
main.c:(.text+0x18f): undefined reference to `glutCreateWindow'
main.c:(.text+0x19f): undefined reference to `glutDisplayFunc'
main.c:(.text+0x1a9): undefined reference to `glutIdleFunc'
main.c:(.text+0x1b3): undefined reference to `glutKeyboardFunc'
main.c:(.text+0x1c4): undefined reference to `glClearColor'
main.c:(.text+0x1d1): undefined reference to `glClearDepth'
main.c:(.text+0x1db): undefined reference to `glDisable'
main.c:(.text+0x1e5): undefined reference to `glEnable'
main.c:(.text+0x1ef): undefined reference to `glDepthFunc'
main.c:(.text+0x1f9): undefined reference to `glEnable'
main.c:(.text+0x203): undefined reference to `glFrontFace'
main.c:(.text+0x20d): undefined reference to `glCullFace'
main.c:(.text+0x217): undefined reference to `glMatrixMode'
main.c:(.text+0x21c): undefined reference to `glLoadIdentity'
main.c:(.text+0x25c): undefined reference to `glMatrixMode'
main.c:(.text+0x266): undefined reference to `glutMainLoop'
scene.o: In function `createCylinder':
scene.c:(.text+0xf6): undefined reference to `cosf'
scene.c:(.text+0x147): undefined reference to `sinf'
scene.c:(.text+0x179): undefined reference to `cosf'
scene.c:(.text+0x1ca): undefined reference to `sinf'
scene.c:(.text+0x201): undefined reference to `cosf'
scene.c:(.text+0x252): undefined reference to `sinf'
scene.c:(.text+0x31b): undefined reference to `glGenBuffers'
scene.c:(.text+0x332): undefined reference to `glBindBuffer'
scene.c:(.text+0x358): undefined reference to `glBufferData'
scene.c:(.text+0x36e): undefined reference to `glEnableClientState'
scene.c:(.text+0x378): undefined reference to `glEnableClientState'
scene.c:(.text+0x394): undefined reference to `glVertexPointer'
scene.c:(.text+0x3ab): undefined reference to `glNormalPointer'
scene.o: In function `sceneInit':
scene.c:(.text+0x3c4): undefined reference to `glCreateProgram'
scene.c:(.text+0x40a): undefined reference to `glLinkProgram'
scene.c:(.text+0x425): undefined reference to `glGetProgramiv'
scene.c:(.text+0x44b): undefined reference to `glGetProgramiv'
scene.c:(.text+0x479): undefined reference to `glGetProgramInfoLog'
scene.c:(.text+0x4b4): undefined reference to `glDeleteProgram'
scene.c:(.text+0x4d5): undefined reference to `glGetUniformLocation'
scene.c:(.text+0x4f2): undefined reference to `glGetUniformLocation'
scene.c:(.text+0x50f): undefined reference to `glGetUniformLocation'
scene.c:(.text+0x5c5): undefined reference to `glLoadIdentity'
scene.c:(.text+0x606): undefined reference to `glTranslatef'
scene.o: In function `sceneRender':
scene.c:(.text+0x61a): undefined reference to `glClear'
scene.c:(.text+0x62c): undefined reference to `glUseProgram'
scene.c:(.text+0x648): undefined reference to `glUniform3fv'
scene.c:(.text+0x664): undefined reference to `glUniform3fv'
scene.c:(.text+0x680): undefined reference to `glUniform3fv'
scene.c:(.text+0x697): undefined reference to `glDrawArrays'
scene.c:(.text+0x6a6): undefined reference to `glUseProgram'
scene.c:(.text+0x6b7): undefined reference to `glPushMatrix'
scene.c:(.text+0x710): undefined reference to `glTranslatef'
scene.c:(.text+0x731): undefined reference to `glColor3fv'
scene.c:(.text+0x753): undefined reference to `glutSolidSphere'
scene.c:(.text+0x758): undefined reference to `glPopMatrix'
scene.c:(.text+0x76b): undefined reference to `glutSwapBuffers'
scene.o: In function `sceneCycle':
scene.c:(.text+0x8c4): undefined reference to `cosf'
scene.c:(.text+0x8f1): undefined reference to `cosf'
scene.c:(.text+0x906): undefined reference to `sinf'
scene.c:(.text+0x933): undefined reference to `sinf'
scene.c:(.text+0x957): undefined reference to `glutPostRedisplay'
shader.o: In function `shaderCompileFromFile':
shader.c:(.text+0x213): undefined reference to `glCreateShader'
shader.c:(.text+0x241): undefined reference to `glShaderSource'
shader.c:(.text+0x250): undefined reference to `glCompileShader'
shader.c:(.text+0x274): undefined reference to `glGetShaderiv'
shader.c:(.text+0x297): undefined reference to `glGetShaderiv'
shader.c:(.text+0x2c2): undefined reference to `glGetShaderInfoLog'
shader.c:(.text+0x2fe): undefined reference to `glDeleteShader'
shader.o: In function `shaderAttachFromFile':
shader.c:(.text+0x34a): undefined reference to `glAttachShader'
shader.c:(.text+0x359): undefined reference to `glDeleteShader'
collect2: error: ld returned 1 exit status
I do have glut and mesa installed and have read on some of the other questions that you should chance something in the order of the makefile but how in this instance?
You need to put $(LDFLAGS) (libraries) after the (object) file names, like
$(CC) $(OBJS) -o glsl_lighting $(LDFLAGS)
As per the online gcc manual for linking options
[...] It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.
So, the object files, using the library functions, should appear before the libraries themselves.
I am trying to compile an example program from the Intel MKL library (/opt/intel/mkl/examples/versionqueryc/). I copied the source code (C-file) to a new directory. I then went and tried to build this example using CMake.
In the course of debugging this, I am stuck when trying to use the following command (isolated from cmake by now).
It doesn't find the Math library but I have -lm included in the linking. So what is going on?
:~/devel/mkl/MKL Test/build$ /usr/bin/gcc -m64 CMakeFiles/mkltest.dir/main.c.o \
> -o mkltest -rdynamic -L/home/myuser/src/intel/mkl/lib/intel64 \
> -lm -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lmkl_cdft_core \
> -lmkl_scalapack_lp64 \
> /home/myuser/src/intel/lib/intel64/libiomp5.so \
> -Wl,-rpath,/home/myuser/src/intel/mkl/lib/intel64:/home/myuser/src/intel/lib/intel64
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `logf'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `atan2'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `sin'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `fabs'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `exp'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `sqrtf'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `cos'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `sqrt'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_sequential.so: undefined reference to `log'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `pow'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `log10'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `ceil'
/home/myuser/src/intel/mkl/lib/intel64/libmkl_core.so: undefined reference to `expf'
collect2: ld returned 1 exit status
Put -lm as the last parameter, the order of parameters is important while linking.
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
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.
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