lordgamez commented on code in PR #1742:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1742#discussion_r1517929222


##########
extensions/grafana-loki/tests/CMakeLists.txt:
##########
@@ -38,6 +40,9 @@ FOREACH(testfile ${GRAFANA_LOKI_TESTS})
     createTests("${testfilename}")
     target_link_libraries(${testfilename} Catch2WithMain)
     target_link_libraries(${testfilename} minifi-grafana-loki)
+    if (WIN32)
+        target_wholearchive_library(${testfilename} grafana-loki-protos)
+    endif()

Review Comment:
   What I experienced was, that when I built a separate server as a separate 
process using the generated source files from the proto files, the test passed 
when communicating with that server.
   
   When I created a separate test file that contained the server and client in 
a single source file (running the server on a separate thread) and linked the 
`minifi-grafana-loki` library the linking failed with the following issue:
   
   ```
   LINK Pass 1: command 
"C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\link.exe
 /nologo @CMakeFiles\lokitest.rsp /out:bin\lokitest.exe 
/implib:extensions\grafana-loki\tests\lokitest.lib /pdb:bin\lokitest.pdb 
/version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console 
/WHOLEARCHIVE:test_base /MANIFEST 
/MANIFESTFILE:extensions\grafana-loki\tests\CMakeFiles\lokitest.dir/intermediate.manifest
 extensions\grafana-loki\tests\CMakeFiles\lokitest.dir/manifest.res" failed 
(exit code 1120) with the following output:
   lokitest.cc.obj : error LNK2019: unresolved external symbol "const 
logproto::PushRequest::`vftable'" (??_7PushRequest@logproto@@6B@) referenced in 
function "public: __cdecl logproto::PushRequest::PushRequest(void)" 
(??0PushRequest@logproto@@QEAA@XZ)
   lokitest.cc.obj : error LNK2019: unresolved external symbol "const 
logproto::PushResponse::`vftable'" (??_7PushResponse@logproto@@6B@) referenced 
in function "public: __cdecl logproto::PushResponse::PushResponse(void)" 
(??0PushResponse@logproto@@QEAA@XZ)
   bin\lokitest.exe : fatal error LNK1120: 2 unresolved externals
   ```
   
   It seems that when the PushRequest and PushResponse are used directly in the 
test source file it fails with link error, but when used only from 
PushGrafanaLokiGrpc processor, the PushRequest and PushResponse are not used in 
the tests and probably removed from the final executable, but this is only my 
guess from this.
   
   I was still experimenting with it and it may be able to remove the 
wholearchive linking, as it seems to be enough for Windows to have a separate 
`grafana-loki-protos` library for the generated proto source files and linked 
to `minifi-grafana-loki` for the symbols to be available for the tests. I 
updated it in e3564ef75b3782c9a77d0dbd6a782d9d8519de1d, we shall see if it 
works in the CI as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to