OpenMPDK / SMDK

SMDK, Scalable Memory Development Kit, is developed for Samsung CXL(Compute Express Link) Memory Expander to enable full-stack Software-Defined Memory system
280 stars 60 forks source link

Build error in comp_api #17

Closed mukeshgarg81 closed 1 year ago

mukeshgarg81 commented 1 year ago

I tried following steps to build smdl_allocator code but facing issue in build "comp_api"

  1. git clone https://github.com/OpenMPDK/SMDK.git
  2. cd SMDK/lib/smdk_allocator
  3. cd jemalloc-5.2.1/
  4. ./autogen.sh && cd ..
  5. make opt_api ///build done
  6. make comp_api //build error

build error logs: root@mukesh-Inspiron-7460:/home/smdk_allocator# make comp_api cd jemalloc-5.2.1 && make -j make[1]: Entering directory '/home/smdk_allocator/jemalloc-5.2.1' make[1]: Leaving directory '/home/smdk_allocator/jemalloc-5.2.1' mkdir -p lib cd ./comp_api && make make[1]: Entering directory '/home/smdk_allocator/comp_api' g++ -Wall -shared -o ../lib/libcxlmalloc.so smdk_comp_api.o cxlmalloc.o cxlmalloc_cpp.o /home/smdk_allocator/comp_api/../core/init.o /home/smdk_allocator/comp_api/../core/alloc.o /home/smdk_allocator/comp_api/../core/config.o -L/home/smdk_allocator/comp_api/../jemalloc-5.2.1/lib/ -Wl,--whole-archive /home/smdk_allocator/comp_api/../jemalloc-5.2.1/lib/libjemalloc_pic.a -Wl,--no-whole-archive -lpthread -ldl -lnuma -lstdc++ /usr/bin/ld: /home/smdk_allocator/comp_api/../jemalloc-5.2.1/lib/libjemalloc_pic.a(jemalloc.pic.o): in function realloc': /home/smdk_allocator/jemalloc-5.2.1/src/jemalloc.c:2653: multiple definition ofrealloc'; smdk_comp_api.o:smdk_comp_api.c:(.text+0x12f): first defined here /usr/bin/ld: /home/smdk_allocator/comp_api/../jemalloc-5.2.1/lib/libjemalloc_pic.a(jemalloc.pic.o): in function malloc': /home/smdk_allocator/jemalloc-5.2.1/src/jemalloc.c:2323: multiple definition ofmalloc'; smdk_comp_api.o:smdk_comp_api.c:(.text+0x20): first defined here /usr/bin/ld: /home/smdk_allocator/comp_api/../jemalloc-5.2.1/lib/libjemalloc_pic.a(jemalloc.pic.o): in function posix_memalign': /home/smdk_allocator/jemalloc-5.2.1/src/jemalloc.c:2393: multiple definition ofposix_memalign'; smdk_comp_api.o:smdk_comp_api.c:(.text+0x1ac): first defined here ....... ...... collect2: error: ld returned 1 exit status make[1]: [Makefile:33: ../lib/libcxlmalloc.so] Error 1 make[1]: Leaving directory '/home/smdk_allocator/comp_api' make: [Makefile:16: comp_api] Error 2

junhyeok-im commented 1 year ago

Hi mukeshgarg81. The reason for the 'multiple definition' error you got seems that jemalloc's function prefix was not specified during the its build. $ /path/to/jemalloc/configure --with-jemalloc-prefix='je_'

To solve the problem more simply,, I recommend you build all libraries through the buildscript we provide than build each library seperately with a command below. $ /path/to/smdk/lib/build_lib.sh smdkmalloc

Thanks!

Junhyeok Im.