I recently encountered this question:
I want to use antlr4 to do syntax analysis in my project, and the language used in my project is C++, I need to compile the link antlr-runtime, in order to meet the needs of multiple platforms, I choose to build from the source code, and put antlr-runtime in the third_party directory.
So in CMakelists part of the source code looks like this:
add_subdirectory(third_party)
add_subdirectory(src)
add_subdirectory(test)
The result I want is to compile the antlr4-runtime library in third_party and link it in src:
find_library(ANTLR4_LIB_PATH antlr4-runtime PATHS ${CMAKE_BINARY_DIR}/lib NO_DEFAULT_PATH)
target_link_libraries(parser_obj ${ANTLR4_LIB_PATH})
But as a result, if I try to compile, I get a problem:
ld: library 'ANTLR4_LIB_PATH-NOTFOUND' not found
However, I found that there is already a library file in the /build/lib directory, so I can compile it the second time. Is there any way to make sure that antlr4 is compiled before find_library
? Or make sure it’s compiled in the right order?
I tried to compile and build the code of my project, but this steadily needed to be compiled twice before success. The first failed because the antlr4-current library file was not found, and the second could be compiled successfully
Yukimi__ is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.