Linking against a library that links against other libraries #1816
-
I am trying to write a premake file for an app that links against a custom library, which in turn links against GLFW. The test premake file looks like this: workspace "HelloWorld"
configurations { "Debug", "Release" }
project "Lib"
kind "SharedLib"
language "C++"
targetdir "bin"
files { "src/**.h", "src/**.cpp" }
includedirs "vendor/glfw/include"
libdirs "vendor/glfw/lib"
links { "glfw3", "opengl32" }
project "App"
kind "ConsoleApp"
language "C++"
targetdir "bin"
staticruntime "On"
files { "app/**.h", "app/**.cpp" }
includedirs { "src", "vendor/glfw/include" }
libdirs "vendor/glfw/lib"
links { "Lib", "glfw3", "gdi32" } The library directory contains a single file with a function that calls some GLFW test code, and the app is comprised of a single file that calls this function; here is a ZIP file containing them both. GLFW was pre-built as a static library here. The problem is that if I don't link Excuse me if this is not the right place to ask these kind of questions, I couldn't find (or understand) a clear answer to this problem elsewhere. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Your // Windows
__declspec(dllexport) int notmain();
// Not-Windows
__attribute__((visibility("default"))) int notmain(); |
Beta Was this translation helpful? Give feedback.
Your
Lib
library doesn't contain any code - functions in headers likehello.h
aren't compiled in the library but in the file that#include
s them, in this caseapp.cpp
. You need to put the contents ofnotmain()
intohello.cpp
and then export it like this:You can see how GLFW does it here and it is used here.