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

How can I use some headers in gc.cpp. #27978

Joowoo30 opened this issue Jan 2, 2020 · 1 comment

How can I use some headers in gc.cpp. #27978

Joowoo30 opened this issue Jan 2, 2020 · 1 comment


Copy link

@Joowoo30 Joowoo30 commented Jan 2, 2020

I forked coreclr code and added some test code in it to analyze gc behavior.
but I can't use #include <dlfcn.h> in it. (Exactly in coreclr/src/gc/gc.cpp)
To solve this problem, I edited CmakeLists files many times (Adding target_link_libraries dl and so on)
but I fail to build coreclr with my code.

how can I use #include <dlfcn.h> in gc.cpp?
I have to use dlopen and dlsym for my test.

I would be really grateful if someone let me know.
Thank you.


This comment has been minimized.

Copy link

@janvorli janvorli commented Jan 4, 2020

We have explicitly disabled including any platform files from coreclr runtime and GC code. Only PAL and standalone GC's GCToOSInterface implemented in gcenv.unix.cpp can include such files.
The reason is that otherwise there would be potential clashes between symbols from the runtime / GC and symbols from the platform headers.

I would suggest adding your functions that need to use stuff from the dlfcn.h to PAL, exposing the function prototypes in pal.h. Then you can call them from GC.
You can stick your code e.g. into this directory: Maybe just put it into for the starters so that you don't have to modify any build system files.

You could also do that in the gcenv.unix.cpp, however this code is used only for a standalone GC shared library that is not used by default (the default is to use the GC embedded into the and it is also not as performant as the embedded GC.

@jeffschwMSFT jeffschwMSFT added the area-GC label Jan 6, 2020
@jkotas jkotas added the question label Jan 11, 2020
@jkotas jkotas closed this Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.