Linker error: struct capnp::_::RawSchema const capnp::schemas

109 views
Skip to first unread message

Pratik Mankawde

unread,
May 10, 2021, 7:04:08 AM5/10/21
to Cap'n Proto

Hi,
I am getting this linking error on VS2019.
LNK2001 unresolved external symbol struct capnp::_::RawSchema const capnp::schemas

I saw that there are other threads discussing similar error but the solution mentioned in them didn't work for me. I am linking against following libs in order:
capnp.lib
capnpc.lib
kj.lib

I tried changing order of these libs, didn't work. I am using following data format in capnp file. In this test project, I am only serializing and de-serializing the data, nothing else.

Following are the VS commands options:

C++: /MP /GS /TP /W4 /Zc:wchar_t /I"D:\ecal\ecal\core\include" /I"D:\ecal\_build\complete\ecal\core\include" /I"D:\ecal\contrib\ecalproto\include" /I"D:\ecal\thirdparty\protobuf\src" /I"D:\capnproto-master\c++\src\capnp\.." /I"D:\capnproto-master\c++\src\kj\.." /Zi /Gm- /O2 /Ob2 /Fd"x64\Release\vc142.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /std:c++14 /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\eCal5SubscriberTest.pch" /diagnostics:column

Linker: /OUT:"D:\Release\eCal5SubscriberTest.exe" /MANIFEST /NXCOMPAT /PDB:"D:\Release\eCal5SubscriberTest.pdb" /DYNAMICBASE "D:\capnproto-master\c++\src\capnp\Release\capnp.lib"  "D:\capnproto-master\c++\src\capnp\Release\capnpc.lib" "D:\ecal\_build\complete\ecal\core\Release\ecal_core.lib" "D:\capnproto-master\c++\src\kj\Release\kj.lib" "D:\lib\zlib.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MACHINE:X64 /INCREMENTAL:NO /PGD:"D:\Release\eCal5SubscriberTest.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"x64\Release\eCal5SubscriberTest.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1


I have tried linking against all of these libs together, but I don't think I need them all:
capnp-json.lib
capnp-rpc.lib
capnp-websocket.lib
capnp.lib
capnpc.lib
kj-http.lib
kj-async.lib
kj-test.lib
kj.lib

Cap'n Proto Root.sln solution builds fine in VS. All tests pass. I get this link error when I use these libs in my test project. I am not getting any other error as of now. I am using master branch from github.
Am I doing something wrong here?

Thanks,
Pratik

Kenton Varda

unread,
May 10, 2021, 10:39:13 AM5/10/21
to Pratik Mankawde, Cap'n Proto
Hi Pratik,

When you run the Cap'n Proto code generator, it produces two files: a header (ending in `.capnp.h`) and a source file (ending in `.capnp.c++`).

Did you make sure to compile the source file into your project?

I'm guessing the missing symbol is from there, since it seems to be something from capnp::schemas, which is what the `.capnp.c++` file provides. (Your error message seems to be cut short, by the way. Your error has the type and namespace of the missing symbol, but not the symbol name, which should have come next.)

BTW, you probably don't need capnpc.lib -- it contains the capnp compiler implementation, used for parsing `.capnp` schema definition files. Most people don't do that at runtime.

-Kenton

--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/1e5ade4b-690f-4bd4-9495-646fa3717850n%40googlegroups.com.

Pratik Mankawde

unread,
May 10, 2021, 1:34:30 PM5/10/21
to Cap'n Proto
Yeah, you were right, although `.capnp.c++`  was added to the project, it was still not getting compiled. VS was ignoring '.c++' extension for compilation.
Thanks for the help.
Reply all
Reply to author
Forward
0 new messages