-
Notifications
You must be signed in to change notification settings - Fork 20
links
Home > [Scripting Reference](Scripting Reference) > links
The links function specifies a list of libraries and projects to link against.
#!lua
links { "references" }
If a project includes multiple calls to links the lists are concatenated, in the order in which they appear in the script.
Solutions, projects, and configurations.
references is a list of library and project names.
When linking against another project in the same solution, specify the project name here, rather than the library name. Premake will figure out the correct library to link against for the current configuration, and will also create a dependency between the projects to ensure a proper build order.
When linking against system libraries, do not include any prefix or file extension. Premake will use the appropriate naming conventions for the current platform.
Link against some system libraries.
#!lua
configuration "windows"
links { "user32", "gdi32" }
configuration "linux"
links { "m", "png" }
configuration "macosx"
-- OS X frameworks need the extension to be handled properly
links { "Cocoa.framework", "png" }
In a solution with two projects, link the library into the executable. Note that the project name is used to specify the link; Premake will automatically figure out the correct library file name and directory and create a project dependency.
#!lua
solution "MySolution"
configurations { "Debug", "Release" }
language "C++"
project "MyExecutable"
kind "ConsoleApp"
files "**.cpp"
links { "MyLibrary" }
project "MyLibrary"
kind "SharedLib"
files "**.cpp"
You may also create links between non-library projects. In this case, Premake will generate a build dependency (the linked project will build first), but not an actual link. In this example, MyProject uses a build dependency to ensure that MyTool gets built first. It then uses MyTool as part of its build process.
#!lua
solution "MySolution"
configurations { "Debug", "Release" }
language "C++"
project "MyProject"
kind "ConsoleApp"
files "**.cpp"
links { "MyTool" }
prebuildcommands { "MyTool --dosomething" }
project "MyTool"
kind "ConsoleApp"
files "**.cpp"