Skip to content

undefined reference to 'FreeLibraryAndExitThread' #22

Description

@nxbear

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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions