I want to use standard c function in one of my function
void print(const char* format,...) {
char buffer[256];
va_list args;
va_start (args, format);
vsnprintf (buffer,256,format, args);
va_end (args);
sendString(buffer);
}
Error coming is
arm-none-eabi-ld -o check.elf -T /home/sanju/Arm/check/other/ROM.ld Serial.o irq.o lowlevel.o main.o startup.o \
-L/usr/arm-none-eabi/lib -lc -lg -lm
/usr/arm-none-eabi/lib/libc.a(lib_a-svfprintf.o): In function `_svfprintf_r':
vfprintf.c:(.text+0x688): undefined reference to `__aeabi_dcmplt'
vfprintf.c:(.text+0xdfc): undefined reference to `__aeabi_dcmpeq'
vfprintf.c:(.text+0x10b4): undefined reference to `__aeabi_dcmpeq'
vfprintf.c:(.text+0x168c): undefined reference to `__aeabi_uldivmod'
vfprintf.c:(.text+0x16a8): undefined reference to `__aeabi_uldivmod'
vfprintf.c:(.text+0x1a48): undefined reference to `__aeabi_dcmpeq'
vfprintf.c:(.text+0x1eac): undefined reference to `__aeabi_dcmpeq'
/usr/arm-none-eabi/lib/libc.a(lib_a-dtoa.o): In function `quorem':
dtoa.c:(.text+0x3c): undefined reference to `__aeabi_uidiv'
/usr/arm-none-eabi/lib/libc.a(lib_a-dtoa.o): In function `_dtoa_r':
dtoa.c:(.text+0x274): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0x360): undefined reference to `__aeabi_ui2d'
dtoa.c:(.text+0x37c): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x388): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x394): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x3a4): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x3b0): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x3c4): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x3d0): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x3e8): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0x418): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0x5a8): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0x5ac): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x5b4): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x5c0): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x5d4): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x608): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x61c): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0x650): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x664): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0x684): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0x688): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x690): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x69c): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x6b0): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x6fc): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x718): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0x73c): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0xa94): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0xaa0): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0xbf8): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0xc2c): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xc58): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0xc80): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0xc90): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0xc9c): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xca8): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0xce8): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0xcf4): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xd08): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0xd10): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0xd24): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xd54): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0xd78): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xd8c): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0xdd0): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xddc): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0xe00): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xe1c): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xe28): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0xe30): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0xe44): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xe64): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0xef0): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0xefc): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xf08): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0xf24): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xf38): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0xf54): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0x10c0): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x10e8): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x1130): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x1144): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x114c): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x1160): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x119c): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x11a8): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x11b0): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x11c8): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x1200): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x120c): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0x12cc): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x12d8): undefined reference to `__aeabi_dcmpge'
dtoa.c:(.text+0x158c): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x159c): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x15b0): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x15bc): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x15ec): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x15f8): undefined reference to `__aeabi_dcmpgt'
/usr/arm-none-eabi/lib/libc.a(lib_a-mprec.o): In function `__ratio':
mprec.c:(.text+0xbc0): undefined reference to `__aeabi_ddiv'
/usr/arm-none-eabi/lib/libc.a(lib_a-mprec.o): In function `_mprec_log10':
mprec.c:(.text+0xbf0): undefined reference to `__aeabi_dmul'
/usr/arm-none-eabi/lib/libc.a(lib_a-svfiprintf.o): In function `_svfiprintf_r':
vfprintf.c:(.text+0xf30): undefined reference to `__aeabi_uldivmod'
vfprintf.c:(.text+0xf4c): undefined reference to `__aeabi_uldivmod'
make: *** [all] Error 1
*** Failure: Exit code 2 ***
My makefile is this
TOOLCHAIN=arm-none-eabi-
ARM_CPU=arm7tdmi
VPATH= /home/sanju/Arm/check/src /home/sanju/Arm/check/other /home/sanju/Arm/check/include
INCLUDE= /home/sanju/Arm/check/include
CCFLAGS= -mcpu=$(ARM_CPU) -mthumb-interwork -ffunction-sections -Os -Wall
ASFLAGS= -mcpu=$(ARM_CPU) -mthumb-interwork -mfpu=softfpa -Wall
all: Serial.o irq.o lowlevel.o main.o startup.o
$(TOOLCHAIN)ld -o check.elf -T /home/sanju/Arm/check/other/ROM.ld Serial.o irq.o
lowlevel.o main.o startup.o \
-L/usr/arm-none-eabi/lib -lc -lg -lm
$(TOOLCHAIN)objcopy -O ihex check.elf check.hex
$(TOOLCHAIN)objcopy -O binary check.elf check.bin
Serial.o : Serial.c Serial.h
$(TOOLCHAIN)gcc $(CCFLAGS) -I$(INCLUDE) -c $<
irq.o : irq.c irq.h lpc214x.h
$(TOOLCHAIN)gcc $(CCFLAGS) -I$(INCLUDE) -c $<
lowlevel.o : lowlevel.c lowlevel.h
$(TOOLCHAIN)gcc $(CCFLAGS) -I$(INCLUDE) -c $<
main.o : main.c lpc214x.h timer0.h Asm.h lowlevel.h type.h Serial.h
$(TOOLCHAIN)gcc $(CCFLAGS) -I$(INCLUDE) -c $<
startup.o : startup.S
$(TOOLCHAIN)as $(ASFLAGS) -o startup.o $<
.PHONY: clean
clean :
rm -rf *.o *.elf *.hex *.o *.bin
In the target all it fails in linking. I have tried the example with arm-elf toolchain there also i am getting some errors.I have googled a lot for it but did not find any solution for it.
Try using gcc as ld frontend.
Change:
$(TOOLCHAIN)ld -o check.elf [...]
into
$(TOOLCHAIN)gcc -o check.elf [...]
GCC knows to add some necessary options when invoking ld.
Do things go any better when adding "-lgcc" to -L?
instead of using ld for linking i used gcc but it was including the supplied crt.o object file so i used -nostartfiles and it worked for me.
Related
I'm trying to compile the following program in Main.c:
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
int main()
{
glfwInit();
return 0;
}
I compile it with:
gcc -m64 -c -g -I"libs/vulkan/include" -I"libs/GLFW/include" -std=c11 -MMD -MP -MF "bin/main.o.d" -o bin/main.o src/Main.c
and link it with:
gcc -m64 -o bin/vulkanfirsttest.exe bin/main.o -L"libs/vulkan/lib" -L"libs/GLFW/lib" -L"C:/msys64/mingw64/lib" -lvulkan-1 -lglfw3 -lgdiplus
It compiles successfully but when I try to link it, it spits out the following errors:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0x8e): undefined reference to `__imp_CreateDCW'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0xc8): undefined reference to `__imp_GetDeviceCaps'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0x123): undefined reference to `__imp_DeleteDC'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0x263): undefined reference to `__imp_GetDeviceCaps'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0x88b): undefined reference to `__imp_GetDeviceCaps'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0x9db): undefined reference to `__imp_GetDeviceCaps'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0xdaa): undefined reference to `__imp_CreateDCW'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0xdb9): undefined reference to `__imp_GetDeviceGammaRamp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0xdc2): undefined reference to `__imp_DeleteDC'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0xf37): undefined reference to `__imp_CreateDCW'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0xf46): undefined reference to `__imp_SetDeviceGammaRamp'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_monitor.c.obj):(.text+0xf4f): undefined reference to `__imp_DeleteDC'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_window.c.obj):(.text+0x21a): undefined reference to `__imp_CreateDIBSection'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_window.c.obj):(.text+0x253): undefined reference to `__imp_CreateBitmap'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_window.c.obj):(.text+0x304): undefined reference to `__imp_DeleteObject'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_window.c.obj):(.text+0x397): undefined reference to `__imp_DeleteObject'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_window.c.obj):(.text+0x432): undefined reference to `__imp_CreateRectRgn'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(win32_window.c.obj):(.text+0x4ab): undefined reference to `__imp_DeleteObject'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(wgl_context.c.obj):(.text+0x16a): undefined reference to `__imp_SwapBuffers'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(wgl_context.c.obj):(.text+0x42d): undefined reference to `__imp_ChoosePixelFormat'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(wgl_context.c.obj):(.text+0x43b): undefined reference to `__imp_SetPixelFormat'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(wgl_context.c.obj):(.text+0xc97): undefined reference to `__imp_DescribePixelFormat'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(wgl_context.c.obj):(.text+0xe81): undefined reference to `__imp_DescribePixelFormat'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(wgl_context.c.obj):(.text+0xe9b): undefined reference to `__imp_SetPixelFormat'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libs/GLFW/lib/libglfw3.a(wgl_context.c.obj):(.text+0x1498): undefined reference to `__imp_DescribePixelFormat'
I found a post that had a similar problem, and the answer was to also link gdi32, but there isn't a gdi32 package in mysys2. There is gdiplus (mingw64/mingw-w64-x86_64-libgdiplus 5.6.1-1), but as you can see that doesn't help.
I'm using Mingw's gcc compiler but when I started using the -std options, the linker started complaining about references (except for -std=gnuXX).
I can't find anything about this (maybe I'm really bad at research) because most of the results are on linux and/or relate to other problems with ld..
Here is the command I typed :
gcc src/main.c -o bin/main.exe -std=c11 The same occurs with c89,c99,c17 etc..
Here is my test code :
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
printf("Cool\n");
return EXIT_SUCCESS;
}
Here is the command output
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(mbrscan.o):(.text+0xb6):
undefined reference to `SetLastError#4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingw32.a(wcharmap.o):(.text+0x208): undefined reference to `WideCharToMultiByte#32'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingwex.a(codeset.o):(.text+0xbe):
undefined reference to `GetCPInfo#8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../libmingwex.a(codeset.o):(.text+0x143): undefined reference to `GetCPInfo#8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_mutex_init_function':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:639: undefined reference to `CreateSemaphoreW#16'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_key_create':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:590: undefined reference to `TlsAlloc#0'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: /home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:597: undefined reference to `__mingwthr_key_dtor'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_getspecific':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:621: undefined reference to `SetLastError#4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_mutex_lock':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:655: undefined reference to `InterlockedIncrement#4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_mutex_unlock':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:689: undefined reference to `InterlockedDecrement#4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: /home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:690: undefined reference to `ReleaseSemaphore#12'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_setspecific':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:629: undefined reference to `TlsSetValue#8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_once':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:562: undefined reference to `InterlockedIncrement#4'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/9.2.0/libgcc_eh.a(emutls.o): in function `_gthread_mutex_lock':
/home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:656: undefined reference to `WaitForSingleObject#8'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: /home/keith/builds/mingw/gcc-9.2.0-mingw32-cross-native/mingw32/libgcc/./gthr-default.h:662: undefined reference to `InterlockedDecrement#4'
collect2.exe: error: ld returned 1 exit status
I'm also wondering if I should use Mingw-w64 or Clang/LLVM instead.. ?
EDIT : It works fine with Mingw-w64 so I switched, thanks !
I have a source, that I'd like to build and link against the libav library on Linux.
I followed the compilation guide of ffmpeg here: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
Everything works.
I build the included examples like this: FFmpeg: building example C codes
It also works.
Now, I'd like to build my own little applications, where I try to learn about using libav. My current problem is, that by using the command line
gcc muxing.c -g -I ../../../ffmpeg_build/include/ -L ../../../ffmpeg_build/lib/ -lavdevice -lavformat -lavfilter -lavcodec -lswresample -lswscale -lavutil -lm -lz -lpthread -lfdk-aac -lmp3lame -lx264 -lva -lX11
I get to this point:
muxing.c: In function ‘write_audio_frame’:
muxing.c:354:5: warning: ‘avcodec_encode_audio2’ is deprecated [-Wdeprecated-declarations]
ret = avcodec_encode_audio2(codecContext, &pkt, frame, &got_packet);
^~~
In file included from ../../../ffmpeg_build/include/libavformat/avformat.h:317:0,
from muxing.c:42:
../../../ffmpeg_build/include/libavcodec/avcodec.h:5418:5: note: declared here
int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
^~~~~~~~~~~~~~~~~~~~~
muxing.c: In function ‘write_video_frame’:
muxing.c:524:5: warning: ‘avcodec_encode_video2’ is deprecated [-Wdeprecated-declarations]
ret = avcodec_encode_video2(codecContext, &pkt, frame, &got_packet);
^~~
In file included from ../../../ffmpeg_build/include/libavformat/avformat.h:317:0,
from muxing.c:42:
../../../ffmpeg_build/include/libavcodec/avcodec.h:5457:5: note: declared here
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
^~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: ../../../ffmpeg_build/lib//libx264.a(opencl-8.o): undefined reference to symbol 'dlclose##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Then I read, in order to overcome this linker error, I have to append -ldl to my command line, but then I get this:
../../../ffmpeg_build/lib//libavcodec.a(libopusdec.o): In function `libopus_flush':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:204: undefined reference to `opus_multistream_decoder_ctl'
../../../ffmpeg_build/lib//libavcodec.a(libopusdec.o): In function `libopus_decode':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:169: undefined reference to `opus_multistream_decode_float'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:165: undefined reference to `opus_multistream_decode'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:174: undefined reference to `opus_strerror'
../../../ffmpeg_build/lib//libavcodec.a(libopusdec.o): In function `libopus_decode_close':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:145: undefined reference to `opus_multistream_decoder_destroy'
../../../ffmpeg_build/lib//libavcodec.a(libopusdec.o): In function `libopus_decode_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:101: undefined reference to `opus_multistream_decoder_create'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:105: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:111: undefined reference to `opus_multistream_decoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:113: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:126: undefined reference to `opus_multistream_decoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusdec.c:129: undefined reference to `opus_strerror'
../../../ffmpeg_build/lib//libavcodec.a(libopusenc.o): In function `libopus_encode':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:487: undefined reference to `opus_multistream_encode'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:483: undefined reference to `opus_multistream_encode_float'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:492: undefined reference to `opus_strerror'
../../../ffmpeg_build/lib//libavcodec.a(libopusenc.o): In function `libopus_encode_close':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:530: undefined reference to `opus_multistream_encoder_destroy'
../../../ffmpeg_build/lib//libavcodec.a(libopusenc.o): In function `libopus_encode_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:348: undefined reference to `opus_multistream_encoder_create'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:358: undefined reference to `opus_multistream_surround_encoder_create'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:365: undefined reference to `opus_strerror'
../../../ffmpeg_build/lib//libavcodec.a(libopusenc.o): In function `libopus_configure_encoder':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:121: undefined reference to `opus_multistream_encoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:123: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:128: undefined reference to `opus_multistream_encoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:131: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:134: undefined reference to `opus_multistream_encoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:136: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:139: undefined reference to `opus_multistream_encoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:142: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:145: undefined reference to `opus_multistream_encoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:148: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:153: undefined reference to `opus_multistream_encoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:156: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:161: undefined reference to `opus_multistream_encoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:164: undefined reference to `opus_strerror'
../../../ffmpeg_build/lib//libavcodec.a(libopusenc.o): In function `libopus_encode_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:410: undefined reference to `opus_multistream_encoder_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:412: undefined reference to `opus_strerror'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libopusenc.c:426: undefined reference to `opus_multistream_encoder_destroy'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisenc.o): In function `libvorbis_encode_frame':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:287: undefined reference to `vorbis_analysis_buffer'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:294: undefined reference to `vorbis_analysis_wrote'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:310: undefined reference to `vorbis_analysis_blockout'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:311: undefined reference to `vorbis_analysis'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:313: undefined reference to `vorbis_bitrate_addblock'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:317: undefined reference to `vorbis_bitrate_flushpacket'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:302: undefined reference to `vorbis_analysis_wrote'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisenc.o): In function `libvorbis_encode_close':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:180: undefined reference to `vorbis_analysis_wrote'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:182: undefined reference to `vorbis_block_clear'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:183: undefined reference to `vorbis_dsp_clear'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:184: undefined reference to `vorbis_info_clear'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisenc.o): In function `libvorbis_encode_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:203: undefined reference to `vorbis_info_init'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisenc.o): In function `libvorbis_setup':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:98: undefined reference to `vorbis_encode_setup_vbr'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:107: undefined reference to `vorbis_encode_setup_managed'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:114: undefined reference to `vorbis_encode_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:121: undefined reference to `vorbis_encode_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:127: undefined reference to `vorbis_encode_ctl'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:160: undefined reference to `vorbis_encode_setup_init'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisenc.o): In function `libvorbis_encode_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:208: undefined reference to `vorbis_analysis_init'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:214: undefined reference to `vorbis_block_init'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:220: undefined reference to `vorbis_comment_init'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:222: undefined reference to `vorbis_comment_add_tag'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:224: undefined reference to `vorbis_analysis_headerout'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisenc.c:257: undefined reference to `vorbis_comment_clear'
../../../ffmpeg_build/lib//libavcodec.a(libvpxdec.o): In function `decode_frame':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:161: undefined reference to `vpx_codec_decode'
../../../ffmpeg_build/lib//libavcodec.a(libvpxdec.o): In function `vpx_decode':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:221: undefined reference to `vpx_codec_get_frame'
../../../ffmpeg_build/lib//libavcodec.a(libvpxdec.o): In function `decode_frame':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:162: undefined reference to `vpx_codec_error'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:163: undefined reference to `vpx_codec_error_detail'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:161: undefined reference to `vpx_codec_decode'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:162: undefined reference to `vpx_codec_error'
../../../ffmpeg_build/lib//libavcodec.a(libvpxdec.o): In function `vpx_decode':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:222: undefined reference to `vpx_codec_get_frame'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:201: undefined reference to `vpx_codec_vp9_dx_algo'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:201: undefined reference to `vpx_codec_vp8_dx_algo'
../../../ffmpeg_build/lib//libavcodec.a(libvpxdec.o): In function `vpx_free':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:269: undefined reference to `vpx_codec_destroy'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:271: undefined reference to `vpx_codec_destroy'
../../../ffmpeg_build/lib//libavcodec.a(libvpxdec.o): In function `vpx_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:53: undefined reference to `vpx_codec_version_str'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:54: undefined reference to `vpx_codec_build_config'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:56: undefined reference to `vpx_codec_dec_init_ver'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:59: undefined reference to `vpx_codec_error'
../../../ffmpeg_build/lib//libavcodec.a(libvpxdec.o): In function `vp8_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:278: undefined reference to `vpx_codec_vp8_dx_algo'
../../../ffmpeg_build/lib//libavcodec.a(libvpxdec.o): In function `vp9_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxdec.c:298: undefined reference to `vpx_codec_vp9_dx_algo'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `vpx_encode':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:1118: undefined reference to `vpx_codec_encode'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:1126: undefined reference to `vpx_codec_encode'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `queue_frames':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:979: undefined reference to `vpx_codec_get_cx_data'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:981: undefined reference to `vpx_codec_get_cx_data'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `log_encoder_error':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:164: undefined reference to `vpx_codec_error'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:165: undefined reference to `vpx_codec_error_detail'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `codecctl_int':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:298: undefined reference to `vpx_codec_control_'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `vpx_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:524: undefined reference to `vpx_codec_get_caps'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:527: undefined reference to `vpx_codec_version_str'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:528: undefined reference to `vpx_codec_build_config'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:533: undefined reference to `vpx_codec_enc_config_default'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:534: undefined reference to `vpx_codec_err_to_string'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:719: undefined reference to `vpx_codec_enc_init_ver'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:727: undefined reference to `vpx_codec_enc_init_ver'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:812: undefined reference to `vpx_img_wrap'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:820: undefined reference to `vpx_img_wrap'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `vp8_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:1279: undefined reference to `vpx_codec_vp8_cx'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `vp9_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:1309: undefined reference to `vpx_codec_vp9_cx'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `codecctl_intp':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:320: undefined reference to `vpx_codec_control_'
../../../ffmpeg_build/lib//libavcodec.a(libvpxenc.o): In function `vpx_free':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:344: undefined reference to `vpx_codec_destroy'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpxenc.c:346: undefined reference to `vpx_codec_destroy'
../../../ffmpeg_build/lib//libavcodec.a(libx265.o): In function `libx265_encode_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libx265.c:84: undefined reference to `x265_api_get_173'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libx265.c:86: undefined reference to `x265_api_get_173'
../../../ffmpeg_build/lib//libavcodec.a(libx265.o): In function `libx265_encode_init_csp':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libx265.c:494: undefined reference to `x265_api_get_173'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libx265.c:496: undefined reference to `x265_api_get_173'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libx265.c:498: undefined reference to `x265_api_get_173'
../../../ffmpeg_build/lib//libavcodec.a(libvpx.o): In function `ff_vp9_init_static':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpx.c:73: undefined reference to `vpx_codec_vp9_cx'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvpx.c:73: undefined reference to `vpx_codec_get_caps'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisdec.o): In function `oggvorbis_decode_close':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:191: undefined reference to `vorbis_block_clear'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:192: undefined reference to `vorbis_dsp_clear'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:193: undefined reference to `vorbis_info_clear'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:194: undefined reference to `vorbis_comment_clear'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisdec.o): In function `oggvorbis_decode_frame':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:169: undefined reference to `vorbis_synthesis'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:175: undefined reference to `vorbis_synthesis_pcmout'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:179: undefined reference to `vorbis_synthesis_read'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:170: undefined reference to `vorbis_synthesis_blockin'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisdec.o): In function `oggvorbis_decode_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:48: undefined reference to `vorbis_info_init'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:49: undefined reference to `vorbis_comment_init'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:97: undefined reference to `vorbis_synthesis_headerin'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisdec.o): In function `oggvorbis_decode_close':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:191: undefined reference to `vorbis_block_clear'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:192: undefined reference to `vorbis_dsp_clear'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:193: undefined reference to `vorbis_info_clear'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:194: undefined reference to `vorbis_comment_clear'
../../../ffmpeg_build/lib//libavcodec.a(libvorbisdec.o): In function `oggvorbis_decode_init':
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:109: undefined reference to `vorbis_synthesis_init'
/home/ritter/ffmpeg_sources/ffmpeg/libavcodec/libvorbisdec.c:110: undefined reference to `vorbis_block_init'
../../../ffmpeg_build/lib//libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_create':
/home/ritter/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:1490: undefined reference to `vaGetDisplay'
/home/ritter/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:1514: undefined reference to `vaGetDisplayDRM'
../../../ffmpeg_build/lib//libavutil.a(hwcontext_vaapi.o): In function `vaapi_device_derive':
/home/ritter/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vaapi.c:1561: undefined reference to `vaGetDisplayDRM'
../../../ffmpeg_build/lib//libavutil.a(hwcontext_vdpau.o): In function `vdpau_device_create':
/home/ritter/ffmpeg_sources/ffmpeg/libavutil/hwcontext_vdpau.c:461: undefined reference to `vdp_device_create_x11'
collect2: error: ld returned 1 exit status
So, what can I do, to get it compiled and linked fully?
I using CLion to write my project,Windows 10 is my OS.
I use MinGw to compile the source code with CMAKE,
and following the wrong message
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_mgr_init':
C:/Users/admin/Desktop/TB2/mongoose.c:2023: undefined reference to `WSAStartup#8'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_mgr_free':
C:/Users/admin/Desktop/TB2/mongoose.c:2081: undefined reference to `closesocket#4'
C:/Users/admin/Desktop/TB2/mongoose.c:2082: undefined reference to `closesocket#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_resolve2':
C:/Users/admin/Desktop/TB2/mongoose.c:2139: undefined reference to `gethostbyname#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_resolve':
C:/Users/admin/Desktop/TB2/mongoose.c:2151: undefined reference to `inet_ntoa#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_parse_address':
C:/Users/admin/Desktop/TB2/mongoose.c:2226: undefined reference to `htonl#4'
C:/Users/admin/Desktop/TB2/mongoose.c:2227: undefined reference to `htons#4'
C:/Users/admin/Desktop/TB2/mongoose.c:2238: undefined reference to `htons#4'
C:/Users/admin/Desktop/TB2/mongoose.c:2246: undefined reference to `htons#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_do_connect':
C:/Users/admin/Desktop/TB2/mongoose.c:2565: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:2565: undefined reference to `inet_ntoa#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_broadcast':
C:/Users/admin/Desktop/TB2/mongoose.c:2763: undefined reference to `send#16'
C:/Users/admin/Desktop/TB2/mongoose.c:2765: undefined reference to `recv#16'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_set_non_blocking_mode':
C:/Users/admin/Desktop/TB2/mongoose.c:2861: undefined reference to `ioctlsocket#12'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_is_error':
C:/Users/admin/Desktop/TB2/mongoose.c:2881: undefined reference to `WSAGetLastError#0'
C:/Users/admin/Desktop/TB2/mongoose.c:2882: undefined reference to `WSAGetLastError#0'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_if_connect_tcp':
C:/Users/admin/Desktop/TB2/mongoose.c:2890: undefined reference to `socket#12'
C:/Users/admin/Desktop/TB2/mongoose.c:2899: undefined reference to `connect#12'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_if_connect_udp':
C:/Users/admin/Desktop/TB2/mongoose.c:2905: undefined reference to `socket#12'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_if_destroy_conn':
C:/Users/admin/Desktop/TB2/mongoose.c:2950: undefined reference to `closesocket#4'
C:/Users/admin/Desktop/TB2/mongoose.c:2953: undefined reference to `closesocket#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_accept_conn':
C:/Users/admin/Desktop/TB2/mongoose.c:2970: undefined reference to `accept#12'
C:/Users/admin/Desktop/TB2/mongoose.c:2977: undefined reference to `closesocket#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_open_listening_socket':
C:/Users/admin/Desktop/TB2/mongoose.c:3001: undefined reference to `socket#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3006: undefined reference to `setsockopt#20'
C:/Users/admin/Desktop/TB2/mongoose.c:3024: undefined reference to `bind#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3025: undefined reference to `listen#8'
C:/Users/admin/Desktop/TB2/mongoose.c:3029: undefined reference to `getsockname#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3032: undefined reference to `closesocket#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_write_to_socket':
C:/Users/admin/Desktop/TB2/mongoose.c:3051: undefined reference to `sendto#24'
C:/Users/admin/Desktop/TB2/mongoose.c:3053: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:3053: undefined reference to `inet_ntoa#4'
C:/Users/admin/Desktop/TB2/mongoose.c:3082: undefined reference to `send#16'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_read_from_socket':
C:/Users/admin/Desktop/TB2/mongoose.c:3127: undefined reference to `recv#16'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_recvfrom':
C:/Users/admin/Desktop/TB2/mongoose.c:3149: undefined reference to `recvfrom#24'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_handle_udp_read':
C:/Users/admin/Desktop/TB2/mongoose.c:3162: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:3162: undefined reference to `inet_ntoa#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_mgr_handle_conn':
C:/Users/admin/Desktop/TB2/mongoose.c:3227: undefined reference to `getsockopt#20'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_mgr_handle_ctl_sock':
C:/Users/admin/Desktop/TB2/mongoose.c:3287: undefined reference to `recv#16'
C:/Users/admin/Desktop/TB2/mongoose.c:3289: undefined reference to `send#16'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_mgr_poll':
C:/Users/admin/Desktop/TB2/mongoose.c:3547: undefined reference to `select#20'
C:/Users/admin/Desktop/TB2/mongoose.c:3553: undefined reference to `__WSAFDIsSet#8'
C:/Users/admin/Desktop/TB2/mongoose.c:3561: undefined reference to `__WSAFDIsSet#8'
C:/Users/admin/Desktop/TB2/mongoose.c:3562: undefined reference to `__WSAFDIsSet#8'
C:/Users/admin/Desktop/TB2/mongoose.c:3563: undefined reference to `__WSAFDIsSet#8'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_socketpair':
C:/Users/admin/Desktop/TB2/mongoose.c:3604: undefined reference to `htons#4'
C:/Users/admin/Desktop/TB2/mongoose.c:3605: undefined reference to `htonl#4'
C:/Users/admin/Desktop/TB2/mongoose.c:3607: undefined reference to `socket#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3608: undefined reference to `bind#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3609: undefined reference to `listen#8'
C:/Users/admin/Desktop/TB2/mongoose.c:3610: undefined reference to `getsockname#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3611: undefined reference to `socket#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3612: undefined reference to `connect#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3614: undefined reference to `getsockname#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3615: undefined reference to `connect#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3617: undefined reference to `accept#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3622: undefined reference to `closesocket#4'
C:/Users/admin/Desktop/TB2/mongoose.c:3627: undefined reference to `closesocket#4'
C:/Users/admin/Desktop/TB2/mongoose.c:3628: undefined reference to `closesocket#4'
C:/Users/admin/Desktop/TB2/mongoose.c:3629: undefined reference to `closesocket#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_sock_get_addr':
C:/Users/admin/Desktop/TB2/mongoose.c:3643: undefined reference to `getpeername#12'
C:/Users/admin/Desktop/TB2/mongoose.c:3645: undefined reference to `getsockname#12'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `deliver_websocket_data':
C:/Users/admin/Desktop/TB2/mongoose.c:4091: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:4094: undefined reference to `ntohl#4'
C:/Users/admin/Desktop/TB2/mongoose.c:4095: undefined reference to `ntohl#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_send_ws_header':
C:/Users/admin/Desktop/TB2/mongoose.c:4193: undefined reference to `htons#4'
C:/Users/admin/Desktop/TB2/mongoose.c:4200: undefined reference to `htonl#4'
C:/Users/admin/Desktop/TB2/mongoose.c:4202: undefined reference to `htonl#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `wait_until_ready':
C:/Users/admin/Desktop/TB2/mongoose.c:5806: undefined reference to `select#20'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `push_to_stdin':
C:/Users/admin/Desktop/TB2/mongoose.c:5815: undefined reference to `recv#16'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `pull_from_stdout':
C:/Users/admin/Desktop/TB2/mongoose.c:5837: undefined reference to `send#16'
C:/Users/admin/Desktop/TB2/mongoose.c:5844: undefined reference to `shutdown#8'
C:/Users/admin/Desktop/TB2/mongoose.c:5845: undefined reference to `closesocket#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `start_process':
C:/Users/admin/Desktop/TB2/mongoose.c:5931: undefined reference to `closesocket#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `handle_cgi':
C:/Users/admin/Desktop/TB2/mongoose.c:6241: undefined reference to `closesocket#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_send_http_file':
C:/Users/admin/Desktop/TB2/mongoose.c:6333: undefined reference to `ntohl#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_sock_addr_to_str':
C:/Users/admin/Desktop/TB2/mongoose.c:6725: undefined reference to `inet_ntoa#4'
C:/Users/admin/Desktop/TB2/mongoose.c:6731: undefined reference to `ntohs#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `parse_mqtt':
C:/Users/admin/Desktop/TB2/mongoose.c:7137: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:7141: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:7148: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:7157: undefined reference to `ntohs#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_send_mqtt_handshake_opt':
C:/Users/admin/Desktop/TB2/mongoose.c:7225: undefined reference to `htons#4'
C:/Users/admin/Desktop/TB2/mongoose.c:7228: undefined reference to `htons#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_mqtt_publish':
C:/Users/admin/Desktop/TB2/mongoose.c:7261: undefined reference to `htons#4'
C:/Users/admin/Desktop/TB2/mongoose.c:7262: undefined reference to `htons#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_mqtt_subscribe':
C:/Users/admin/Desktop/TB2/mongoose.c:7280: undefined reference to `htons#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj):C:/Users/admin/Desktop/TB2/mongoose.c:7285: more undefined references to `htons#4' follow
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_dns_encode_record':
C:/Users/admin/Desktop/TB2/mongoose.c:7699: undefined reference to `htonl#4'
C:/Users/admin/Desktop/TB2/mongoose.c:7714: undefined reference to `htons#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_send_dns_query':
C:/Users/admin/Desktop/TB2/mongoose.c:7751: undefined reference to `htons#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_parse_dns':
C:/Users/admin/Desktop/TB2/mongoose.c:7823: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:7824: undefined reference to `ntohs#4'
C:/Users/admin/Desktop/TB2/mongoose.c:7825: undefined reference to `ntohs#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `dns_handler':
C:/Users/admin/Desktop/TB2/mongoose.c:7906: undefined reference to `htons#4'
CMakeFiles\TB2.dir/objects.a(mongoose.c.obj): In function `mg_resolve_from_hosts_file':
C:/Users/admin/Desktop/TB2/mongoose.c:8132: undefined reference to `htonl#4'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\TB2.dir\build.make:225: recipe for target 'TB2.exe' failed
mingw32-make.exe[2]: *** [TB2.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/TB2.dir/all] Error 2
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/TB2.dir/all' failed
Makefile:82: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2
and my Cmake write like this
cmake_minimum_required(VERSION 3.3)
project(TB2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
set(CMAKE_C_FLAGS "-std=c99 -static-libgcc -w -lpthread -lws2_32 -fopenmp -lwsock32")
set(SOURCE_FILES main.c r2nat_to_local.h mongoose.c mongoose.h sqlite3.c sqlite3.h TUtility.c TUtility.h cJSON.c cJSON.h url_parser.c url_parser.h)
add_executable(TB2 ${SOURCE_FILES})
target_link_libraries(TB2 sqlite3)
add_definitions(-DUNICODE -D_UNICODE -DMG_ENABLE_THREADS -DDEBUG -DDEBUG -DHAVE_MD5 -DRA100)
I don't know where is worng. After I add -lws2_32 -fopenmp -lwsock32
How to fix the error?
I'm trying to compile COSEG, a program from the RepeatMasker developers (link: http://www.repeatmasker.org/COSEGDownload.html) on Xubuntu.
After unpacking the distribution I enter the directory and try to run make in my terminal but I get many "undefined reference to" errors:
massimiliano#compaq2:~/Programs/coseg$ make
cc -O4 -lm version.o coseg.o -o coseg
coseg.o: In function `compute_siegel_tri_pvalue.part.0':
coseg.c:(.text+0xa1): undefined reference to `log'
coseg.c:(.text+0xae): undefined reference to `exp'
coseg.c:(.text+0x47b): undefined reference to `log'
coseg.c:(.text+0x4c2): undefined reference to `exp'
coseg.c:(.text+0x4d7): undefined reference to `log'
coseg.c:(.text+0x683): undefined reference to `log'
coseg.c:(.text+0x6d7): undefined reference to `exp'
coseg.c:(.text+0x6e4): undefined reference to `log'
coseg.c:(.text+0x70f): undefined reference to `sqrt'
coseg.c:(.text+0x72d): undefined reference to `sqrt'
coseg.c:(.text+0x757): undefined reference to `sqrt'
coseg.o: In function `compute_siegel_pvalue.part.1':
coseg.c:(.text+0x7da): undefined reference to `log'
coseg.c:(.text+0x7e7): undefined reference to `exp'
coseg.c:(.text+0x97f): undefined reference to `exp'
coseg.c:(.text+0x98c): undefined reference to `log'
coseg.c:(.text+0x9ff): undefined reference to `log'
coseg.c:(.text+0xad7): undefined reference to `exp'
coseg.c:(.text+0xae4): undefined reference to `log'
coseg.c:(.text+0xb4d): undefined reference to `log'
coseg.c:(.text+0xbe7): undefined reference to `sqrt'
coseg.c:(.text+0xc05): undefined reference to `sqrt'
coseg.o: In function `compute_pvalue.part.2':
coseg.c:(.text+0xd3b): undefined reference to `log'
coseg.c:(.text+0xd4c): undefined reference to `log'
coseg.c:(.text+0xe24): undefined reference to `exp'
coseg.c:(.text+0xe86): undefined reference to `log'
coseg.c:(.text+0xe97): undefined reference to `log'
coseg.o: In function `compute_tri_pvalue.part.3':
coseg.c:(.text+0x10e4): undefined reference to `exp'
coseg.o: In function `inverseNormalCDF':
coseg.c:(.text+0x141e): undefined reference to `log'
coseg.c:(.text+0x150f): undefined reference to `sqrt'
coseg.o: In function `allocate_memory':
coseg.c:(.text+0x15de): undefined reference to `log'
coseg.c:(.text+0x166c): undefined reference to `log'
coseg.c:(.text+0x16cc): undefined reference to `log'
coseg.o: In function `compute_tri_pvalue':
coseg.c:(.text+0x303a): undefined reference to `log'
coseg.c:(.text+0x3047): undefined reference to `exp'
coseg.o: In function `compute_pvalue':
coseg.c:(.text+0x31e6): undefined reference to `log'
coseg.c:(.text+0x31f3): undefined reference to `exp'
coseg.o: In function `compute_score':
coseg.c:(.text+0x32cd): undefined reference to `log'
coseg.c:(.text+0x32da): undefined reference to `exp'
coseg.o: In function `compute_tri_score':
coseg.c:(.text+0x3386): undefined reference to `log'
coseg.c:(.text+0x3393): undefined reference to `exp'
coseg.o: In function `compute_tri_bestmut':
coseg.c:(.text+0x628c): undefined reference to `log'
coseg.c:(.text+0x629b): undefined reference to `exp'
coseg.o: In function `split_pvaluelocal':
coseg.c:(.text+0x6e55): undefined reference to `log'
coseg.c:(.text+0x734d): undefined reference to `log'
coseg.c:(.text+0x735a): undefined reference to `exp'
coseg.o: In function `compute_bestmut':
coseg.c:(.text+0x7ff3): undefined reference to `log'
coseg.c:(.text+0x8000): undefined reference to `exp'
coseg.o: In function `union_tri_pvalue':
coseg.c:(.text+0x91fd): undefined reference to `log'
coseg.c:(.text+0x920a): undefined reference to `exp'
coseg.c:(.text+0x934e): undefined reference to `log'
coseg.c:(.text+0x935b): undefined reference to `exp'
coseg.o: In function `union_pvalue':
coseg.c:(.text+0x9e1c): undefined reference to `log'
coseg.c:(.text+0x9e29): undefined reference to `exp'
coseg.o: In function `build_MST':
coseg.c:(.text+0xb232): undefined reference to `exp'
coseg.o: In function `compute_sigma':
coseg.c:(.text+0xb7d4): undefined reference to `log'
coseg.c:(.text+0xb7e1): undefined reference to `exp'
coseg.o: In function `compute_bestmut1':
coseg.c:(.text+0xbb27): undefined reference to `log'
coseg.c:(.text+0xbb34): undefined reference to `exp'
coseg.o: In function `build_new_subfamily2':
coseg.c:(.text+0xd265): undefined reference to `exp'
coseg.c:(.text+0xd2a6): undefined reference to `log'
coseg.c:(.text+0xd4ad): undefined reference to `exp'
coseg.c:(.text+0xd4ee): undefined reference to `log'
coseg.o: In function `sigmage_to_logpvalue':
coseg.c:(.text+0xd8a8): undefined reference to `exp'
coseg.c:(.text+0xd8ec): undefined reference to `log'
coseg.o: In function `build_new_singlemut_subfamily':
coseg.c:(.text+0xdb4d): undefined reference to `exp'
coseg.c:(.text+0xdb8e): undefined reference to `log'
coseg.c:(.text+0xdd7d): undefined reference to `exp'
coseg.c:(.text+0xddbe): undefined reference to `log'
coseg.o: In function `build_singlemut_MST':
coseg.c:(.text+0xe608): undefined reference to `log'
coseg.c:(.text+0xe615): undefined reference to `exp'
coseg.c:(.text+0xe8ce): undefined reference to `log'
coseg.c:(.text+0xe8db): undefined reference to `exp'
coseg.o: In function `build_MST2':
coseg.c:(.text+0xf38f): undefined reference to `exp'
coseg.c:(.text+0xf5d0): undefined reference to `exp'
coseg.c:(.text+0xf7c9): undefined reference to `exp'
coseg.c:(.text+0xf814): undefined reference to `log'
coseg.c:(.text+0xf85f): undefined reference to `exp'
coseg.c:(.text+0xfb3c): undefined reference to `exp'
coseg.c:(.text+0xfb97): undefined reference to `log'
coseg.c:(.text+0xfbf6): undefined reference to `exp'
coseg.c:(.text+0xfcd8): undefined reference to `sqrt'
coseg.c:(.text+0xfd51): undefined reference to `sqrt'
coseg.o: In function `print_subfamilies':
coseg.c:(.text+0xffe0): undefined reference to `exp'
coseg.c:(.text+0x10024): undefined reference to `log'
collect2: ld returned 1 exit status
make: *** [coseg] Error 1
Searching the internet I have found that probably it is a 'linking' problem and I have to add/modify some lines of code in the makefile but this kind of stuffs are very new to me and I am not a programmer, so I feel a bit confused.
Do you have some tips or suggestions to help me to solve this problem, please?
Thank you very much for your time!
Massimiliano.
Update:
Trying to compile the previous version of the program, gives me an additional warning:
echo "char const* Version = \"0.2.1\";" > version.c
cc -O4 -lm -c -o version.o version.c
cc -O4 -lm -c -o coseg.o coseg.c
coseg.c: In function ‘inverseNormalCDF’:
coseg.c:973:5: warning: format ‘%lf’ expects a matching ‘double’ argument [-Wformat]
Update - Makefile:
This is the Makefile unpacked with the distribution:
##
## Makefile for coseg project
##
VERSION=0.2.2
INSTALLDIR=/usr/local/coseg-${VERSION}
## Basic
CC = cc -O4 -lm
## A nice memory leak checker:
#CC = bgcc -O4 -fbounds-checking -lm
all: coseg
version.c: Makefile
echo "char const* Version = \"$(VERSION)\";" > version.c
coseg: version.o coseg.o
${CC} version.o coseg.o -o coseg
beautify:
indent -bap -cdb -bl -bli0 -npcs -nut -lp coseg.c
install: coseg
-mkdir ${INSTALLDIR}
cp coseg ${INSTALLDIR}
cp README ${INSTALLDIR}
cp preprocessAlignments.pl ${INSTALLDIR}
cp postprocess.pl ${INSTALLDIR}
cp runcoseg.pl ${INSTALLDIR}
cp extractSubSeqs.pl ${INSTALLDIR}
cp refineConsSeqs.pl ${INSTALLDIR}
cp ALU.cons ${INSTALLDIR}
cp ALU.ins ${INSTALLDIR}
cp ALU.seqs ${INSTALLDIR}
cp LINE1 ${INSTALLDIR}
dist:
-mkdir dist
-mkdir dist/coseg
cp ALU.cons dist/coseg
cp ALU.ins dist/coseg
cp ALU.seqs dist/coseg
cp LINE1 dist/coseg
cp Makefile dist/coseg
cp README dist/coseg
cp coseg.c dist/coseg
cp coseg.h dist/coseg
cp postprocess.pl dist/coseg
cp preprocessAlignments.pl dist/coseg
cp runcoseg.pl dist/coseg
cp extractSubSeqs.pl dist/coseg
cp refineConsSeqs.pl dist/coseg
(cd dist; tar zcvf coseg-$(VERSION).tar.gz coseg)
clean:
-rm *.o
-rm coseg
-rm version.c
-rm ALU.seqs.subfamilies.seq
-rm ALU.seqs.assign
-rm ALU.seqs.log
-rm ALU.seqs.subfamilies
-rm ALU.seqs.tree.viz
ALU.seqs.subfamilies.seq: coseg
./runcoseg.pl -d -filePrefix ALU
t/kothi.seqs.subfamilies.seq: coseg
./runcoseg.pl -u1 -t -m 5 -filePrefix t/kothi
test: ALU.seqs.subfamilies.seq t/kothi.seqs.subfamilies.seq
diff ALU.seqs.subfamilies.seq t
diff t/kothi.seqs.subfamilies.seq t/kothi-baseline
Some linkers (including yours) need to have the libraries specified after the object files (or other libraries), which use symbols from it. This can even lead to the necessity to specify libraries multiply if cyclic dependencies are involved.
In your case coseg.o uses symbols from libm, so you would have to specify -lm after coseg.o in your command: cc -O4 version.o coseg.o -lm -o coseg
I suggest you change your Makefile to:
##
## Makefile for coseg project
##
VERSION=0.2.2
INSTALLDIR=/usr/local/coseg-${VERSION}
## Basic
CC = cc
CFLAGS = -O4
LDFLAGS = -lm
## A nice memory leak checker:
#CC = bgcc -O4 -fbounds-checking -lm
all: coseg
version.c: Makefile
echo "char const* Version = \"$(VERSION)\";" > version.c
coseg: version.o coseg.o
${CC} version.o coseg.o ${LDFLAGS} -o coseg
... rest of makefile ...
That should fix your problem.