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

Unable to figure out how to link surelog as a CMake package #3964

Open
mysoreanoop opened this issue Apr 25, 2024 · 1 comment
Open

Unable to figure out how to link surelog as a CMake package #3964

mysoreanoop opened this issue Apr 25, 2024 · 1 comment

Comments

@mysoreanoop
Copy link

I'm trying to use Surelog as an external package when compiling a custom visitor outside of Surelog's directory or install path. But I see unrecognized UHDM functions. Could I be missing explicitly specifying any UHDM related info my CMakeLists?

PS: Surelog is not installed in the default path, I ran make install PREFIX=<custom path> which is the same as in the CMakeLists.txt file.

The CMakeLists.txt file is as below:

cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(ExampleProject)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/../import/black-parrot-tools/surelog_install)

find_package(Surelog REQUIRED)

# these were added because my system was unable to find libsurelog.a
link_directories(${CMAKE_SOURCE_DIR}/../import/black-parrot-tools/surelog_install/lib/surelog)
find_library(SURELOG_LIBRARY NAMES surelog PATHS /home/mysanoop/zynq-farm/zynq-parrot/cosim/import/black-parrot-tools/surelog_install/lib/surelog)
if(NOT SURELOG_LIBRARY)
    message(FATAL_ERROR "Surelog library not found")
endif()
# these were added because my system complained as shown in the error log
link_directories(${CMAKE_SOURCE_DIR}/../import/black-parrot-tools/surelog_install/lib/uhdm)
find_library(UHDM_LIBRARY NAMES uhdm PATHS /home/mysanoop/zynq-farm/zynq-parrot/cosim/import/black-parrot-tools/surelog_install/lib/uhdm)
if(NOT UHDM_LIBRARY)
    message(FATAL_ERROR "UHDM library not found")
endif()

add_executable(example instrumentation/walker.cpp)
target_link_libraries(example surelog)
target_include_directories(example PRIVATE ${SURELOG_INCLUDE_DIRS})

When I run this with cmake -S . -B out && make -C out, here's the error log after the linking stage:

<path as above>/surelog_install/lib/surelog/libsurelog.a(Surelog.cpp.o): In function `SURELOG::shutdown_compiler(SURELOG::scompiler*)':
Surelog.cpp:(.text+0xba): undefined reference to `UHDM::Serializer::Purge()'
<path as above>/surelog_install/lib/surelog/libsurelog.a(CommandLineParser.cpp.o): In function `SURELOG::CommandLineParser::processOutputDirectory_(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)':
CommandLineParser.cpp:(.text+0x2f46): undefined reference to `UHDM::SymbolFactory::add(std::basic_string_view<char, std::char_traits<char> >)'
... (goes on)
@alaindargelas
Copy link
Collaborator

This project uses Surelog successfully:
https://github.com/chipsalliance/synlig/blob/main/CMakeLists.txt
Use it as an example.

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