Author Topic: Problem: static library linked with a dynamic library  (Read 2762 times)

Trixter

  • Guest
Problem: static library linked with a dynamic library
« on: February 15, 2008, 08:09:18 am »
Hey!

I have created a dynamic library that is an application framework and I'm linking it with another project that is the actual application. However I'm having a problem with a static LUA library that I'm linking with the framework. Everything is fine when I compile the framework (framework.dll) but compiling the application I'm linking the framework with fails (undefined reference to 'luaL_newstate). If I also link the actual application with the static LUA library it works like a charm...why? Shouldn't the static LUA code be embedded in the dynamic framework library? What am I doing wrong here? How should it be done? I really dont want to link lua with the application code too.

I wish to do this:

libLua5.1.a --linking with--> framework.dll --linking with--> application.exe

NOT THIS:

libLua5.1.a --linking with--> framework.dll --linking with--> application.exe
libLua5.1.a ------------------linking with---------------->


BTW: I'm using Code::Blocks + MinGW on Windows.

Trixter

  • Guest
Re: Problem: static library linked with a dynamic library
« Reply #1 on: February 15, 2008, 09:38:44 am »
Ahh...I think I got it... :D

Added to "Other Link Options" (dll):

-Wl,--whole-archive
libMylib.a
-Wl,--no-whole-archive

I also removed my libraries from "Link Libraries".