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

如何使用mimalloc静态库 #110

Open
Lawliet828 opened this issue Apr 15, 2024 · 1 comment
Open

如何使用mimalloc静态库 #110

Lawliet828 opened this issue Apr 15, 2024 · 1 comment

Comments

@Lawliet828
Copy link

Lawliet828 commented Apr 15, 2024

What happened + What you expected to happen

co_context使用的mimalloc动态库

if (CO_CONTEXT_USE_MIMALLOC)
    target_link_libraries(co_context PUBLIC mimalloc)
endif()

在一些生产环境的机器上安装mimalloc动态库比较困难,可以增加使用静态库的编译方式吗

我尝试直接将cmake改为mimalloc-static没有编译成功

if (CO_CONTEXT_USE_MIMALLOC)
    target_link_libraries(co_context PUBLIC mimalloc-static)
endif()
@Codesire-Deng
Copy link
Owner

Codesire-Deng commented Apr 15, 2024

链接 mimalloc 静态库

根据官方示例,直接使用 mimalloc-static 很可能会不成功,官方建议尝试这么做:

if (CO_CONTEXT_USE_MIMALLOC)
-   target_link_libraries(co_context PUBLIC mimalloc)
+   target_link_libraries(co_context PUBLIC ${MIMALLOC_OBJECT_DIR}/mimalloc.o)
+   target_include_directories(co_context PUBLIC ${MIMALLOC_INCLUDE_DIR})
endif()

不使用 mimalloc

如果 cmake 没有找到 mimalloc,co_context 就会自动放弃。如果 cmake 找到了 mimalloc 但你不想使用,也可以这样修改:

if (mi_version)
-   set(CO_CONTEXT_USE_MIMALLOC ON)
+   set(CO_CONTEXT_USE_MIMALLOC OFF)
-   message(NOTICE "mimalloc ${mi_version} enabled")
else()

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

2 participants