0

I am trying to use MinGW to compile Linux project into Windows. I have been successful doing so with Cygwin, but I would match rather prefer to use MinGW so I the program does not end up having dozens of unnecessary dependencies.

Unfortunately, I have run into a problem that the compiler complains of unidentified references to the file. I am using a precompiled version of FFTW3 for Windows and using dlltool to create .a files to link it to MinGW. I have specified the libpath for the compiler, but unfortunately, I am still encountering errors.

Here is my output:

make all gcc -I../Include -L..\Lib -Wall -O3 -o lvdoenc lvdoenc.o lvdomain.o -I../Include -L..\Lib -m32 lvdoenc.o:lvdoenc.c:(.text+0x29b): undefined reference to _imp__fftw_execute' lvdoenc.o:lvdoenc.c:(.text+0x608): undefined reference to_imp__fftw_malloc' lvdoenc.o:lvdoenc.c:(.text+0x647): undefined reference to _imp__fftw_plan_r2r_2d' lvdoenc.o:lvdoenc.c:(.text+0x8d1): undefined reference to_imp__fftw_free' lvdoenc.o:lvdoenc.c:(.text+0x8e5): undefined reference to _imp__fftw_destroy_plan' c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: lvdoenc.o: bad reloc address 0x20 in section.eh_frame' c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation collect2.exe: error: ld returned 1 exit status make: *** [lvdoenc] Error 1

13:23:28 Build Finished (took 217ms)

All the solutions I have come across involve compiling using gcc to link fftw3 (-lfftw3), but this does not work in MinGW. I am having the same problem in the Cygwin, but that solution of using -lfftw3 as a compiler option does work. I have even specified the location of the lib path. The include path works just fine, but it can't find the library in the libpath.

Any help would be great appreciated.

6
  • 1
    -lfftw3 must be given, without it the linker can't resolve the symbols from this library. You should add what's not working when you compile with -lfftw3. I just downloaded the dlls, used dlltool and tried to link a symbol of the fftw3-library with MinGW and it worked. Commented Jun 1, 2015 at 18:13
  • Does MinGW's gcc or linker know how to handle Windows style paths? Cause that's what your feeding to it (..**\**Lib). Also you're passing the include and lib paths twice. Commented Jun 1, 2015 at 18:20
  • Okay, so I used the Windows compiled binaries and just got it to recognize it by changing it to -lfftw3-3, it still is not linking properly. I think it can handle Windows style path because the include path is written the same way and it works just fine. @4566976 Really? where did you get the dlls from? I tried their website and the libraries would not link. I am using Eclipse as my IDE btw. Interestingly enough, some of the symbols do actually link properly, but others are not. Commented Jun 1, 2015 at 18:24
  • @4566976 I just learned some of the distributions of the libs are actually missing certain symbols. Where did you downlaod those Dlls from? Commented Jun 1, 2015 at 18:28
  • @Skylion: I downloaded them from here. dlltool -d libfftw3-3.def -l libfftw3.a int main() { fftw_malloc(); } gcc x.c -L.\. -lfftw3 Commented Jun 1, 2015 at 18:29

1 Answer 1

2

I downloaded the DLLs from here.

Then I've done the following (see http://www.mingw.org/wiki/createimportlibraries):

dlltool -d libfftw3-3.def -l libfftw3.a

/* x.c */ int main() { fftw_malloc(); } 

gcc x.c -L.\. -lfftw3

Sign up to request clarification or add additional context in comments.

1 Comment

Hi, I have tried the method above. Still I am getting the following error C:\GNUstep\bin/ld.exe: cannot find -lfftw3 collect2: ld returned 1 exit status

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.