Git Product home page Git Product logo

Comments (7)

dczaretsky avatar dczaretsky commented on May 2, 2024 2

According to the CMake configuration, you should include the -std=c++11 option for g++. I'm using -std=c++14 in my program compilation, and that also works.

from cld3.

ekalchev avatar ekalchev commented on May 2, 2024

Thanks for the info. It was useful although I needed to build .lib for windows with visual studio. My first attempt was use GN build tool and modify BUILD.gn Ρ„Π°ΠΉΠ». It was very straight forward but unfortunately chrome uses clang and use_clang = false is not available. I used this setup

gn gen --args="is_debug=false is_component_build=false target_cpu="x64" use_lld=false" out/x64.release

On theory using VS2019 with clang should work but I got many unresolved externals during the linking and I gave up.

My approach to this was to avoid clang and build all dependencies with VS2017

  1. Follow the steps for buidling cld_3

  2. Build protobuf from source with Visual Studio and cmake matching the chromium protobuf version (currently 3.9.0)
    Directory location of the source C:/protobuf/protobuf-3.9.0

Add these lines to C:\chromium\src\third_party\cld_3\src\CMakeList.txt with correct path pointing to your directory location

Add this as first line in the file cmake_policy(SET CMP0091 NEW) to allow usage of CMAKE_MSVC_RUNTIME_LIBRARY

set (Protobuf_INCLUDE_DIR "C:/protobuf/protobuf-3.9.0/src")
set (Protobuf_LIBRARIES "C:/protobuf/protobuf-3.9.0/cmake/build/solution/Release")
set (Protobuf_LITE_LIBRARIES "C:/protobuf/protobuf-3.9.0/cmake/build/solution/Release")
set (Protobuf_PROTOC_EXECUTABLE "C:/protobuf/protobuf-3.9.0/cmake/build/solution/Release/protoc.exe")
set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")

I am not sure if this is needed but I added it because of the post above

install(DIRECTORY include/ DESTINATION include)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

replace
add_executable(language_identifier_main src/language_identifier_main.cc)
target_link_libraries(language_identifier_main cld3 ${Protobuf_LITE_LIBRARIES})

with
link_directories(C:/protobuf/protobuf-3.9.0/cmake/build/solution/Release)
add_executable(language_identifier_main src/language_identifier_main.cc)
target_link_libraries(language_identifier_main cld3 ${Protobuf_LITE_LIBRARIES})
target_link_libraries(language_identifier_main cld3 libprotobuf.lib)
target_link_libraries(language_identifier_main cld3 libprotobuf-lite.lib)
target_link_libraries(language_identifier_main cld3 libprotoc.lib)

  1. Execute in cmd.exe

cd "C:\chromium\src\third_party\cld_3\src"
mkdir build
cd build

for x64 build

cmake -G "Visual Studio 15 2017 Win64" -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=../../../../install ../..

You should be able to build language_identifier_main.vcproj.

This is my cmake file

https://gist.github.com/ekalchev/493c3790cdb7378dc7d1db48fabc8705

from cld3.

gnanaravindhan avatar gnanaravindhan commented on May 2, 2024

@dczaretsky , Thanks for the steps able to successfully build libcld3.a but When am trying to execute the C++ code am getting following error in RHEL, any idea

cld3test.cc:(.text+0x6f): undefined reference to chrome_lang_id::NNetLanguageIdentifier::NNetLanguageIdentifier()'
cld3test.cc:(.text+0x8f): undefined reference to chrome_lang_id::NNetLanguageIdentifier::FindLanguage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' cld3test.cc:(.text+0x111): undefined reference to chrome_lang_id::NNetLanguageIdentifier::~NNetLanguageIdentifier()'
cld3test.cc:(.text+0x166): undefined reference to chrome_lang_id::NNetLanguageIdentifier::~NNetLanguageIdentifier()'

from cld3.

dczaretsky avatar dczaretsky commented on May 2, 2024

@gnanaravindhan sounds like maybe the library was not linked to your program or include files were not found. You might want to check where the include and lib files were installed, then compile with -I and -L parameters to provide their paths respectively, like this:

g++ -I/usr/local/include -L/usr/local/lib -lcld3 cld3test.cc -o cld3test

from cld3.

gnanaravindhan avatar gnanaravindhan commented on May 2, 2024

g++ -I/usr/local/include -L/usr/local/lib -lcld3 cld3test.cc -o cld3test

@dczaretsky Thanks for your response, as recommended i've tried the same, but no luck. following is the command which am executing

g++ -I/opt/rh/vcpkg/installed/x64-linux/include -I/usr/local/include -L/usr/local/lib -lcld3 cld3test.cc -o cld3test

from cld3.

gnanaravindhan avatar gnanaravindhan commented on May 2, 2024

I've sorted out the issue, after changing the
-D_GLIBCXX_USE_CXX11_ABI=0 to -D_GLIBCXX_USE_CXX11_ABI=1
it's started working fine.
@dczaretsky Thanks for your help

from cld3.

mickeyzo12 avatar mickeyzo12 commented on May 2, 2024

I have error as below, could you please help me how to solve it?

cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --target install

output is:
`C:\Users\HardW\Downloads\cld3-master\build.release>cmake .. -DCMAKE_BUILD_TYPE=Release
CMake Error at CMakeLists.txt:3 (project):
Running

'nmake' '-?'

failed with:

The system cannot find the file specified

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/HardW/Downloads/cld3-master/build.release/CMakeFiles/CMakeOutput.log"`

from cld3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.