Reputation: 11
I'm trying to build a project using Premake5 on an Android environment, and I'm encountering a linker error related to libc++_shared.so
. Below are the details of the problem and what I've tried so far.
Here is the premake5.lua
script I'm using:
local ocgcore_config=function()
files { "*.h", "*.hpp", "*.cpp", "RNG/*.hpp", "RNG/*.cpp" }
warnings "Extra"
cppdialect "C++17"
rtti "Off"
filter "configurations:Release"
optimize "Speed"
filter "configurations:Debug"
optimize "Off"
filter "action:not vs*"
buildoptions { "-Wno-unused-parameter", "-pedantic" }
filter "system:linux"
linkoptions { "-Wl,--no-undefined" }
filter { "system:macosx", "files:processor_visit.cpp" }
buildoptions { "-fno-exceptions" }
filter {}
include "./lua/"
links { "lua" }
includedirs { "lua/src" }
end
if not subproject then
newoption {
trigger = "oldwindows",
description = "Use the v141_xp toolset to support windows XP sp3"
}
workspace "ocgcore"
location "build"
language "C++"
objdir "obj"
configurations { "Debug", "Release" }
symbols "On"
staticruntime "on"
startproject "ocgcoreshared"
filter "system:windows"
defines { "WIN32", "_WIN32", "NOMINMAX" }
platforms {"Win32", "x64", "arm", "arm64"}
filter "platforms:Win32"
architecture "x86"
filter "platforms:x64"
architecture "x64"
filter "platforms:arm64"
architecture "ARM64"
filter "platforms:arm"
architecture "ARM"
filter { "action:vs*", "platforms:Win32 or x64" }
vectorextensions "SSE2"
if _OPTIONS["oldwindows"] then
toolset "v141_xp"
end
filter "action:vs*"
flags "MultiProcessorCompile"
filter "configurations:Debug"
defines "_DEBUG"
targetdir "bin/debug"
runtime "Debug"
filter "configurations:Release"
defines "NDEBUG"
targetdir "bin/release"
local function set_target_dir(target,arch)
filter { "system:windows", "configurations:" .. target, "architecture:" .. arch }
targetdir("bin/" .. arch .. "/" .. target)
end
set_target_dir("debug","x64")
set_target_dir("debug","arm")
set_target_dir("debug","arm64")
set_target_dir("release","x64")
set_target_dir("release","arm")
set_target_dir("release","arm64")
filter { "action:not vs*", "system:windows" }
buildoptions { "-static-libgcc", "-static-libstdc++", "-static" }
linkoptions { "-static-libgcc", "-static-libstdc++", "-static" }
defines { "UNICODE", "_UNICODE" }
filter { "system:linux" }
includedirs { "lua/src" }
linkoptions { "-static-libgcc", "-static-libstdc++" }
filter { "system:android" }
libdirs { "$(NDK_HOME)/toolchains/llvm/prebuilt/linux-aarch64/sysroot/usr/lib/aarch64-linux-android" }
links { "c++_shared" }
linkoptions { "-L$(NDK_HOME)/toolchains/llvm/prebuilt/linux-aarch64/sysroot/usr/lib/aarch64-linux-android -lc++_shared" }
local function disableWinXPWarnings(prj)
premake.w('<XPDeprecationWarning>false</XPDeprecationWarning>')
end
local function vcpkgStaticTriplet202006(prj)
premake.w('<VcpkgEnabled>false</VcpkgEnabled>')
premake.w('<VcpkgUseStatic>false</VcpkgUseStatic>')
premake.w('<VcpkgAutoLink>false</VcpkgAutoLink>')
end
require('vstudio')
premake.override(premake.vstudio.vc2010.elements, "globals", function(base, prj)
local calls = base(prj)
table.insertafter(calls, premake.vstudio.vc2010.targetPlatformVersionGlobal, disableWinXPWarnings)
table.insertafter(calls, premake.vstudio.vc2010.globals, vcpkgStaticTriplet202006)
return calls
end)
end
project "ocgcore"
kind "StaticLib"
ocgcore_config()
project "ocgcoreshared"
kind "SharedLib"
flags "NoImportLib"
-- filter "configurations:Release"
-- flags "LinkTimeOptimization"
-- filter {}
targetname "ocgcore"
defines "OCGCORE_EXPORT_FUNCTIONS"
staticruntime "on"
visibility "Hidden"
ocgcore_config()
I have set the NDK_HOME
environment variable in my .bashrc
file:
export NDK_HOME=$HOME/android-ndk-r26b
I verified the path by listing the contents:
ls $NDK_HOME/toolchains/llvm/prebuilt/linux-aarch64/sysroot/usr/lib/aarch64-linux-android | grep libc++_shared.so
Despite these configurations, I am still encountering the following error:
ld.lld: error: unable to find library -lc++_shared
aarch64-linux-android-clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [ocgcoreshared.make:111: ../bin/release/libocgcore.so] Error 1
make: *** [Makefile:46: ocgcoreshared] Error 2
What am I missing or doing wrong in this setup? How can I resolve the linker error related to libc++_shared.so
?
Thank you for any assistance!
Upvotes: 0
Views: 148