Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to 'FreeLibraryAndExitThread' #22

Open
nxbear opened this issue Dec 7, 2022 · 0 comments
Open

undefined reference to 'FreeLibraryAndExitThread' #22

nxbear opened this issue Dec 7, 2022 · 0 comments

Comments

@nxbear
Copy link

nxbear commented Dec 7, 2022

Hello.

I'm trying to use the FreeLibraryAndExitThread function for detaching a profiler from CLR.
so I've build a coreclr and link my profiler with 'libcoreclrpal.a' library.

But when I try to build my profiler, linker outputs error like this

/usr/bin/ld: /tmp/MODProfiler-7b0549.o: in function `MODProfiler::InitializeForAttach(IUnknown*, void*, unsigned int)':
MODProfiler.cpp:(.text+0xf48): undefined reference to `FreeLibraryAndExitThread'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there any manual about how to link with coreclr static library for profiler?
I don't know what cause of this error.

this is my build.sh file

#!/bin/sh

[ -z "${CORECLR_PATH:-}" ] && CORECLR_PATH=~/coreclr
[ -z "${BuildOS:-}"      ] && BuildOS=Linux
[ -z "${BuildArch:-}"    ] && BuildArch=x64
[ -z "${BuildType:-}"    ] && BuildType=Debug
[ -z "${Output:-}"       ] && Output=CorProfiler.so

printf '  CORECLR_PATH : %s\n' "$CORECLR_PATH"
printf '  BuildOS      : %s\n' "$BuildOS"
printf '  BuildArch    : %s\n' "$BuildArch"
printf '  BuildType    : %s\n' "$BuildType"

printf '  Building %s ... ' "$Output"

CXX_FLAGS="$CXX_FLAGS --no-undefined -Wno-invalid-noreturn -fPIC -fms-extensions -DBIT64 -DPAL_STDCPP_COMPAT -DPLATFORM_UNIX -std=c++11"
INCLUDES="-I $CORECLR_PATH/src/pal/inc/rt -I $CORECLR_PATH/src/pal/prebuilt/inc -I $CORECLR_PATH/src/pal/inc -I $CORECLR_PATH/src/inc -I $CORECLR_PATH/bin/Product/$BuildOS.$BuildArch.$BuildType/inc"
LIBS="-lpthread -L $CORECLR_PATH/bin/Product/Linux.x64.Release/lib -lcoreclrpal"
SOURCE="ClassFactory.cpp MODProfiler.cpp dllmain.cpp Common.cpp ProfileManager.cpp FunctionMapper.cpp FunctionInfo.cpp Logger.cpp MetaDataUtil.cpp StringUtil.cpp ThreadManager.cpp CallstackInfo.cpp TreeNode.cpp sigparse.cpp SignatureParser.cpp Setting.cpp Environment.cpp"

clang++ -shared -o $Output $CXX_FLAGS $INCLUDES $LIBS $SOURCE $CORECLR_PATH/src/pal/prebuilt/idl/corprof_i.cpp

printf 'Done.\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant