Compiling a shared library on windows with undefined symbol

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi.

I'm trying to compile file "test.c" with gcc 8.1 on Windows. The file
contains following code:

	__declspec( dllimport ) void foo(void);

	__declspec( dllexport ) void bar(void)
	{
        	foo();
	}

The compilation step works fine:
	C:\test>gcc -m64 -c test.c -o test.o

The linking step fails:
	C:\test>gcc -m64 -shared -o Test.dll test.o
	test.o:test.c:(.text+0xb): undefined reference to `__imp_foo'
	collect2.exe: error: ld returned 1 exit status

Similar code on Linux works fine and generates a shared library with
undefined symbol "foo". That is what I want to do on Windows too.

The goal is to create an application that uses Test.dll and also another
shared library FooLib.dll which _does_ define the "foo()" function - i.e.
at the dynamic linking step during process creation the symbol _will_ be
available.

I would prefer to _not_ add library FooLib to the linking step of Test.dll
due circular dependencies.

How can this be solved?
--
	regards
		Rastislav Stanik



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux