I'm creating a grammar to run a console application, using VSCode or IntelliJ extensions everything seems fine with my .g4 grammar file. But when I execute the command to get the antlr/parser folder:
antlr4 -Dlanguage=Go -o parser items.g4
I get the following errors from the items_lexer.go and items_parser.go files:
Unresolved reference 'DeserializeFromUInt16'
Unresolved reference 'DecisionToState'
Unresolved reference 'DecisionToState'
The first one appears in the following line:
var lexerAtn = lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn)
Which uses the var: lexerDeserializer declared in the previous line:
var lexerDeserializer = antlr.NewATNDeserializer(nil)
And here is the origin of the problem, directly from antlr lib for some reason the DeserializeFromUInt16 func is not founded. I already tried using another grammar. Im using ANTRL 4.7.2, and I made sure to had a jdk installed, the go get github.com/antlr/antlr4/runtime/Go/antlr, and the .jar folder in my project.
I would appreciate any kind of suggestions about how can I free my files from errors.
Related
I am running gosec on my project but it gives following error due to which our pipeline is failing
Golang errors in file: [/home/usr/exmaple/project.go]:
[line 22 : column 8] - could not import C (no metadata for C)
While go build command successfully builds the project means there is no golang error.
This is not an issue.
We found out that our C code is present in .c and .h files in package directory, where .h file containing only function prototypes. And we are including only .h file in go files (cgo).
go build and go test commands are working because both of these commands when see .c and .h in package directory, compiles and link them.
But gosec is a SAST tool, it doesn't compile .c and .h files present in package directory due to this gosec scan was getting only function prototypes not definition and was throwing Golang error could not import C (no metadata for C).
Including the whole code in comments (CGO) worked. Now gosec works fine.
This seems to be a bug encoutered by other people as well. See this issue or this one. You should probably report an issue to gosec as well for this. Or maybe about the go/packages package in the Go repo directly.
I have a CMake setup to link together 4 static libraries and 1 shared one into a top level shared library (Let's call it Top.dll). This will work fine except for one thing. I have a module definition file that expresses which symbols should be public. Top.dll builds and so far so good.
Now when I try to link an executable with Top.dll via CMake I get linker errors for every public symbol claiming it is defined in two places (Top.dll and the static library in which it was actually defined) even though Top.dll contains no original definitions of its own. If I remove the static library then as expected I get unresolved symbol errors. If I remove the module definition file, I get the same. It seems like it is either there zero times or twice. Is there some setting I am missing here? I don't think I'm using CMake in a non-basic way...
UPDATE An explanation via CMake
# setup the lib
add_subdirectory(vendor/A) #shared library
add_subdirectory(vendor/B) #static library
add_subdirectory(vendor/C) #static library
add_library(Top SHARED ${ALL_SRC_FILES})
target_link_libraries(Top A B C)
set_target_properties(Top PROPERTIES LINK_FLAGS
"/def:${PROJECT_SOURCE_DIR}/definitions.def") #contains symbols from B
add_subdirectory(C/Tests)
# CMakeLists.txt from C/Tests
add_executable(Tests ${SRC_FILES})
target_link_libraries(Tests Top)
The above is simplified, but I will get errors like the following at the point that the C/tests project is compiled:
B.lib(xxx.obj) : error LNK2005: _ABC already defined in Top.lib(Top.dll)
If I remove B.lib from the target_link_libraries call, then as expected I get unresolved symbols. If I remove the /def line, same result.
I've been able to get around this by setting the target_link_libraries of B and C to private. This may or may not be the correct solution and I will wait for other answers. If I don't do this it appears that the dependency is carried up to the final executable (So it links to both Top.dll and B.lib, etc).
Here’s my setup:
Static library of Objective C code called Stat.
A Swift framework that uses code from Stat in its own classes (this framework is called Dyn). The static library and this framework are in the same Xcode project.
A Mac app / project that has the above project as a subproject and which links to Dyn.
In my app I have code like:
import Cocoa
import Dyn
...
SomeDynClass().doSomething()
However, when I try to compile I get an error when I import Dyn. The error is
error: missing required module ‘Stat'
It appears my app can find my framework just fine, but it somehow needs to find a module for my static library, too?
Stat has a module file that’s pretty basic:
module Stat {
header "Stat.h"
export *
}
I think I need to point my Mac app’s framework search paths at Stat but I don’t know why and I don’t know how. How do I solve this?
Select your Target, then go into Build Settings and set the Import Paths within the Swift Compiler - Search Paths section:
${SRCROOT}/Stat
Normally the module would be named the same as the library, however, I'm not sure how you've setup the directory with the module.map (it could be named Dyn perhaps, in which case the Import Path would reflect that name.
Build Settings > Swift Compiler > Search Paths:
${SRCROOT}/(directory with module.map) should resolve itself once
you press enter or tab..
I got the same error when in my unit tests project which involves SQLite3 package. After I add the package, unit tests always throw out error saying "missing required module SQLiteObjc"
I had it fixed by toggle "Force Package Info Generation" on and off in my Unit Tests Target's build setting
I'm trying to compile the MultiBoost Library with C++11 but I can't make it work. The problem seems to be with the BZip2 Library that is used internally. More specificly there is a wrapper called Bzip2Wrapper to provide a c++ interface to the C library. All the files of the C library are included in the same folder. When using the default make file everything works but when I change
project(multiboost)
to
project(multiboost CXX)
I get the following errors:
libMultiBoostLib.a(Serialization.cpp.o): In function `Bzip2WrapperReader::open(char const*)':
Serialization.cpp:(.text._ZN18Bzip2WrapperReader4openEPKc[_ZN18Bzip2WrapperReader4openEPKc]+0x97): undefined reference to `BZ2_bzReadOpen'
Serialization.cpp:(.text._ZN18Bzip2WrapperReader4openEPKc[_ZN18Bzip2WrapperReader4openEPKc]+0xc5): undefined reference to `BZ2_bzReadClose'
libMultiBoostLib.a(Serialization.cpp.o): In function `Bzip2WrapperReader::close()': ...
The CMakeList file looks like this
# Bzip2
file(GLOB bzip2_SRCS "${BASEPATH}/Bzip2/*.cpp" "${BASEPATH}/Bzip2/*.c" "${BASEPATH}/Bzip2/*.h")
add_library(Bzip2Lib STATIC ${bzip2_SRCS})
#add_library(bzip2 SHARED ${bzip2_lib_SRCS})
...
# adding library to the exec
target_link_libraries(multiboost MultiBoostLib Bzip2Lib)
Any ideas what could go wrong? I don't even know what the problem is.
Thanks!
This does not look like a C++11 error but an error in the Build system.
I have not looked at the Code, but from the output you added something like this
target_link_libraries(MultiBoostLib PUBLIC Bzip2Lib)
should add the missing dependency from libMultiBoostLib on libBzip2Lib.
I found the problem. I was adding "CXX" to my project description which disabled the use of C. Therefore the libraries (in C) could not be compiled. Changing it to "project(name C CXX)" solved this issue. I then also needed to include the line "set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")" to enable C++11 support. Now everything is working.
Thanks a lot!
I am compiling my project in the release mode in VC++.
I have a .def file where i have declared the setLog and now i
am getting following error
Linking...
Creating library Release/HKL.lib and object Release/HKL.exp
HKL_libinterface.obj : error LNK2001: unresolved external symbol _SCTP_setLog#8
Please help me on the above to fix the problem.
Thanks
It sounds to me like you have a lib file configured in your debug build that is not in the release build. Your setLog() function does not seem to be the function the linker is complaining about - it sounds like it's not finding a function called SCTP_setLog().
Look in the list of libraries you have configured in your project's debug configuration and make sure they are also configured in the release configuration.
If this compiles in Debug mode the most possible reason is that somehow the code where this function is implemented is not included into build - for example, the cpp file where it is implemented has "Excluded from build" set.
As sharptooth mentioned, you most likely are not compiling the above function in your release build. In addition to looking for 'Excluded from build', check if you have any defines set (or not set) that would exclude the missing function from your release build.