Page 1 of 1

Static linking (.lib) in C++

Posted: Sun Mar 04, 2018 4:43 pm
by nicalmacha
Hi all,

Is there any tutorial how to statically link library into my game.dll ? Back in the days, it was easy in CryEngine 3.x, even with Waf build system, it was not really hard, but I'm new to cmake and new CryEngine version (I'm switching a projet from 3.6.15 to 5.4 !), so any help could be helpfull...

Today, I'm plane to use VRPN system into CryEngine, and why not WiiUse libs. I succeed in the old time, but here, it is just how to make my project take in count this libs. (Flowgraph, nodes and other will naturally follow and won't be a problem)

Thanks in advance,

Nicolas

Re: Static linking (.lib) in C++

Posted: Mon Mar 05, 2018 11:57 am
by mknmknmknjk
ue4 or unity has its own build system. but you can use old way to add lib or dll .just search .lib keyword in source code.

Code: Select all

CryBrofilerConfig.cmake(12): set_target_properties(CryBrofiler PROPERTIES INTERFACE_LINK_LIBRARIES "${CRYENGINE_SOURCE_DIR}/Code/SDKs/Brofiler/ProfilerCore64.lib") \FbxSdk.cmake(19): IMPORTED_IMPLIB_DEBUG "${SDK_DIR}/FbxSdk/lib/${FBX_SUBFOLDER}/x64/debug/libfbxsdk-md.lib") \PortAudio.cmake(4):set(LIBSNDFILE_LIB_NAME libsndfile-1.lib) FrameProfiler_impl.pc.h(20):LINK_THIRD_PARTY_LIBRARY("SDKs/GPA/lib64/libittnotify.lib") EyeTrackerInput.cpp(15):#pragma comment (lib, "Tobii.EyeX.Client.lib") StdAfx.h(234): #define NV_API_LIB "SDKs/NVIDIA/NVAPI_r386/amd64/nvapi64.lib" FrameProfileRender.cpp(31):LINK_SYSTEM_LIBRARY("psapi.lib")

Re: Static linking (.lib) in C++

Posted: Mon Mar 05, 2018 2:25 pm
by sunnlok
There is a cmake function for this.
As simple as adding target_link_libraries (${THIS_PROJECT} PRIVATE CryUQS_Shared) to your projects cmakelists.txt

Re: Static linking (.lib) in C++

Posted: Wed Mar 07, 2018 4:01 pm
by nicalmacha
Thanks Guys,

I used Sunnlok process with this lines in my cmakeLists.txt :

Code: Select all

add_library(vrpn STATIC IMPORTED) set_property(TARGET vrpn PROPERTY IMPORTED_LOCATION "${PROJECT_DIR}/bin/win_x64/vrpnd.lib") target_link_libraries(${THIS_PROJECT} PRIVATE vrpn)
It works well !