Fix error LNK1107 and undeclared identifier 'IPPROTO_TCP' (#244)
When I [Update](https://github.com/microsoft/vcpkg/pull/32747) etcd-cpp-apiv3 version from 0.14.2 to 0.15.2, I get two build error: ```` fatal error LNK1107: invalid or corrupt file: cannot read at 0x330 ```` ```` error: use of undeclared identifier 'IPPROTO_TCP' ```` The first error was because the target `etcd-cpp-api-core-objects` linked the wrong `libprotobufd.dll` file instead of the .lib file, I used the usage provided by vcpkg to link the correct .lib file to fix this error. Another error was because `IPPROTO_TCP` was missing declaration `"<netinet/in.h>"`, I added it to fix this error. --------- Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com> Co-authored-by: Zhao Liu <v-zhli17@microsoft.com> Co-authored-by: Tao He <linzhu.ht@alibaba-inc.com>
This commit is contained in:
parent
0eee75b52e
commit
e5dc903a5d
|
|
@ -22,20 +22,28 @@ use_cxx(etcd-cpp-api-core-objects)
|
||||||
add_dependencies(etcd-cpp-api-core-objects protobuf_generates)
|
add_dependencies(etcd-cpp-api-core-objects protobuf_generates)
|
||||||
include_generated_protobuf_files(etcd-cpp-api-core-objects)
|
include_generated_protobuf_files(etcd-cpp-api-core-objects)
|
||||||
target_link_libraries(etcd-cpp-api-core-objects PUBLIC
|
target_link_libraries(etcd-cpp-api-core-objects PUBLIC
|
||||||
${PROTOBUF_LIBRARIES}
|
|
||||||
${OPENSSL_LIBRARIES}
|
${OPENSSL_LIBRARIES}
|
||||||
${GRPC_LIBRARIES}
|
${GRPC_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
if(TARGET protobuf::libprotobuf)
|
||||||
|
target_link_libraries(etcd-cpp-api-core-objects PUBLIC protobuf::libprotobuf)
|
||||||
|
else()
|
||||||
|
target_link_libraries(etcd-cpp-api-core-objects PUBLIC ${PROTOBUF_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(BUILD_ETCD_CORE_ONLY)
|
if(BUILD_ETCD_CORE_ONLY)
|
||||||
# add the core library, includes the sycnhronous client only
|
# add the core library, includes the sycnhronous client only
|
||||||
add_library(etcd-cpp-api-core $<TARGET_OBJECTS:etcd-cpp-api-core-objects>)
|
add_library(etcd-cpp-api-core $<TARGET_OBJECTS:etcd-cpp-api-core-objects>)
|
||||||
use_cxx(etcd-cpp-api-core)
|
use_cxx(etcd-cpp-api-core)
|
||||||
target_link_libraries(etcd-cpp-api-core PUBLIC
|
target_link_libraries(etcd-cpp-api-core PUBLIC
|
||||||
${PROTOBUF_LIBRARIES}
|
|
||||||
${OPENSSL_LIBRARIES}
|
${OPENSSL_LIBRARIES}
|
||||||
${GRPC_LIBRARIES}
|
${GRPC_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
if(TARGET protobuf::libprotobuf)
|
||||||
|
target_link_libraries(etcd-cpp-api-core PUBLIC protobuf::libprotobuf)
|
||||||
|
else()
|
||||||
|
target_link_libraries(etcd-cpp-api-core PUBLIC ${PROTOBUF_LIBRARIES})
|
||||||
|
endif()
|
||||||
include_generated_protobuf_files(etcd-cpp-api-core)
|
include_generated_protobuf_files(etcd-cpp-api-core)
|
||||||
else()
|
else()
|
||||||
# add the client with asynchronus client
|
# add the client with asynchronus client
|
||||||
|
|
@ -44,10 +52,14 @@ else()
|
||||||
use_cxx(etcd-cpp-api)
|
use_cxx(etcd-cpp-api)
|
||||||
target_link_libraries(etcd-cpp-api PUBLIC
|
target_link_libraries(etcd-cpp-api PUBLIC
|
||||||
${CPPREST_LIB} # n.b.: the asynchronous client requires pplx in cpprestsdk
|
${CPPREST_LIB} # n.b.: the asynchronous client requires pplx in cpprestsdk
|
||||||
${PROTOBUF_LIBRARIES}
|
|
||||||
${OPENSSL_LIBRARIES}
|
${OPENSSL_LIBRARIES}
|
||||||
${GRPC_LIBRARIES}
|
${GRPC_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
if(TARGET protobuf::libprotobuf)
|
||||||
|
target_link_libraries(etcd-cpp-api PUBLIC protobuf::libprotobuf)
|
||||||
|
else()
|
||||||
|
target_link_libraries(etcd-cpp-api PUBLIC ${PROTOBUF_LIBRARIES})
|
||||||
|
endif()
|
||||||
include_generated_protobuf_files(etcd-cpp-api)
|
include_generated_protobuf_files(etcd-cpp-api)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue