yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

cmake with mingw64 make

Open yushuiqiang opened this issue 4 years ago • 7 comments

D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:19:8: error: 'YAML::Node::Node()' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline Node::Node() ^~~~ D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:45:8: error: 'YAML::Node::Node(const YAML::Node&)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline Node::Node(const Node&) = default; ^~~~ D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:47:8: error: 'YAML::Node::Node(YAML::Node::Zombie)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline Node::Node(Zombie) ^~~~ D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:56:8: error: 'YAML::Node::~Node()' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline Node::~Node() = default; ^~~~ D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:68:13: error: 'bool YAML::Node::IsDefined() const' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline bool Node::IsDefined() const { ^~~~ D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:82:24: error: 'YAML::NodeType::value YAML::Node::Type() const' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline NodeType::value Node::Type() const { ^~~~ D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:166:27: error: 'const string& YAML::Node::Scalar() const' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline const std::string& Node::Scalar() const { ^~~~ D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:209:14: error: 'YAML::Node& YAML::Node::operator=(const YAML::Node&)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline Node& Node::operator=(const Node& rhs) { ^~~~ D:/mingw64lib/YAML_CPP/include/yaml-cpp/node/impl.h:254:13: error: 'void YAML::Node::AssignNode(const YAML::Node&)' redeclared without dllimport attribute after being referenced with dll linkage [-Werror] inline void Node::AssignNode(const Node& rhs) {

yushuiqiang avatar Dec 09 '21 12:12 yushuiqiang

Can you provide your full command line, and OS and version, etc.?

jbeder avatar Dec 10 '21 14:12 jbeder

Can you provide your full command line, and OS and version, etc.?

Hi, I meet the same issue. OS: Win10 version: newest command: mkdir build cd build cmake .. mingw32-make.exe No errors appears! But when I try to link the generated static library "libyaml-cppd.a" using another program and try to edit an Node ,the errors emerge.

HuNingHe avatar Jan 16 '22 08:01 HuNingHe

I have the same problem. I am building on Windows 10 with mingw. My build commands are as follows:

git clone https://github.com/jbeder/yaml-cpp.git
cd yaml-cpp
mkdir build
cd build
cmake -G "MinGW Makefiles" ..
make
make install

When I execute "make" I get the errors as listed in the OP. Then, when I try to build another project (a Qt project with qmake) that links to the libyaml-cpp.a library, I get a large amount of linking errors:

debug/_db.o: In function `set_profile_directory(QString)':
C:\Users\vagrant\twitter_offline_gui\test\gen/../../src/models/_db.cpp:40: undefined reference to `__imp__ZN4YAML8LoadFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
debug/_db.o: In function `YAML::Exception::Exception(YAML::Mark const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h:156: undefined reference to `__imp__ZTVN4YAML9ExceptionE'
debug/_db.o: In function `YAML::RepresentationException::RepresentationException(YAML::Mark const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h:189: undefined reference to `__imp__ZTVN4YAML23RepresentationExceptionE'
debug/_db.o: In function `YAML::InvalidNode::InvalidNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h:233: undefined reference to `__imp__ZTVN4YAML11InvalidNodeE'
debug/_db.o: In function `YAML::detail::memory_holder::create_node()':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/memory.h:38: undefined reference to `__imp__ZN4YAML6detail6memory11create_nodeEv'
debug/_db.o: In function `YAML::detail::node_ref::mark_defined()':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h:30: undefined reference to `__imp__ZN4YAML6detail9node_data12mark_definedEv'
debug/_db.o: In function `YAML::detail::node_ref::set_null()':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h:36: undefined reference to `__imp__ZN4YAML6detail9node_data8set_nullEv'
debug/_db.o: In function `YAML::detail::node_ref::set_scalar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h:37: undefined reference to `__imp__ZN4YAML6detail9node_data10set_scalarERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
debug/_db.o: In function `YAML::detail::node_ref::size() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h:41: undefined reference to `__imp__ZNK4YAML6detail9node_data4sizeEv'
debug/_db.o: In function `YAML::Node::EnsureNodeExists() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:60: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
debug/_db.o: In function `YAML::Node::Type() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:84: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
debug/_db.o: In function `YAML::Node::Scalar[abi:cxx11]() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:168: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:169: undefined reference to `__imp__ZN4YAML6detail9node_data12empty_scalarB5cxx11Ev'
debug/_db.o: In function `YAML::Node::is(YAML::Node const&) const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:197: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
debug/_db.o: In function `YAML::Node::AssignNode(YAML::Node const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:256: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:266: undefined reference to `__imp__ZN4YAML6detail13memory_holder5mergeERS1_'
debug/_db.o: In function `YAML::Node::size() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:273: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
debug/_db.o: In function `YAML::detail::node& YAML::detail::node_data::get<char [6]>(char const (&) [6], std::shared_ptr<YAML::detail::memory_holder>)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h:154: undefined reference to `__imp__ZN4YAML6detail9node_data14convert_to_mapERKSt10shared_ptrINS0_13memory_holderEE'
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h:157: undefined reference to `__imp__ZN4YAML12BadSubscriptD1Ev'
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h:170: undefined reference to `__imp__ZN4YAML6detail9node_data15insert_map_pairERNS0_4nodeES3_'
debug/_db.o: In function `YAML::BadSubscript::BadSubscript<char [6]>(YAML::Mark const&, char const (&) [6])':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h:264: undefined reference to `__imp__ZTVN4YAML12BadSubscriptE'
debug/_db.o: In function `YAML::detail::node& YAML::detail::node_data::convert_to_node<char [6]>(char const (&) [6], std::shared_ptr<YAML::detail::memory_holder>)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h:229: undefined reference to `__imp__ZN4YAML6detail13memory_holder5mergeERS1_'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile.Debug:292: debug/test-twitter.exe] Error 1
make[1]: Leaving directory 'C:/Users/vagrant/twitter_offline_gui/test/gen'
make: *** [Makefile:45: debug] Error 2

I checked the libyaml-cpp.a file using nm, and it has these symbols but without the __imp_ prefix.

playfulpachyderm avatar Feb 10 '22 05:02 playfulpachyderm

I have the same problem. I am building on Windows 10 with mingw. My build commands are as follows:

git clone https://github.com/jbeder/yaml-cpp.git
cd yaml-cpp
mkdir build
cd build
cmake -G "MinGW Makefiles" ..
make
make install

When I execute "make" I get the errors as listed in the OP. Then, when I try to build another project (a Qt project with qmake) that links to the libyaml-cpp.a library, I get a large amount of linking errors:

debug/_db.o: In function `set_profile_directory(QString)':
C:\Users\vagrant\twitter_offline_gui\test\gen/../../src/models/_db.cpp:40: undefined reference to `__imp__ZN4YAML8LoadFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
debug/_db.o: In function `YAML::Exception::Exception(YAML::Mark const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h:156: undefined reference to `__imp__ZTVN4YAML9ExceptionE'
debug/_db.o: In function `YAML::RepresentationException::RepresentationException(YAML::Mark const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h:189: undefined reference to `__imp__ZTVN4YAML23RepresentationExceptionE'
debug/_db.o: In function `YAML::InvalidNode::InvalidNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h:233: undefined reference to `__imp__ZTVN4YAML11InvalidNodeE'
debug/_db.o: In function `YAML::detail::memory_holder::create_node()':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/memory.h:38: undefined reference to `__imp__ZN4YAML6detail6memory11create_nodeEv'
debug/_db.o: In function `YAML::detail::node_ref::mark_defined()':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h:30: undefined reference to `__imp__ZN4YAML6detail9node_data12mark_definedEv'
debug/_db.o: In function `YAML::detail::node_ref::set_null()':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h:36: undefined reference to `__imp__ZN4YAML6detail9node_data8set_nullEv'
debug/_db.o: In function `YAML::detail::node_ref::set_scalar(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h:37: undefined reference to `__imp__ZN4YAML6detail9node_data10set_scalarERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'
debug/_db.o: In function `YAML::detail::node_ref::size() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h:41: undefined reference to `__imp__ZNK4YAML6detail9node_data4sizeEv'
debug/_db.o: In function `YAML::Node::EnsureNodeExists() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:60: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
debug/_db.o: In function `YAML::Node::Type() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:84: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
debug/_db.o: In function `YAML::Node::Scalar[abi:cxx11]() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:168: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:169: undefined reference to `__imp__ZN4YAML6detail9node_data12empty_scalarB5cxx11Ev'
debug/_db.o: In function `YAML::Node::is(YAML::Node const&) const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:197: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
debug/_db.o: In function `YAML::Node::AssignNode(YAML::Node const&)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:256: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:266: undefined reference to `__imp__ZN4YAML6detail13memory_holder5mergeERS1_'
debug/_db.o: In function `YAML::Node::size() const':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h:273: undefined reference to `__imp__ZN4YAML11InvalidNodeD1Ev'
debug/_db.o: In function `YAML::detail::node& YAML::detail::node_data::get<char [6]>(char const (&) [6], std::shared_ptr<YAML::detail::memory_holder>)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h:154: undefined reference to `__imp__ZN4YAML6detail9node_data14convert_to_mapERKSt10shared_ptrINS0_13memory_holderEE'
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h:157: undefined reference to `__imp__ZN4YAML12BadSubscriptD1Ev'
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h:170: undefined reference to `__imp__ZN4YAML6detail9node_data15insert_map_pairERNS0_4nodeES3_'
debug/_db.o: In function `YAML::BadSubscript::BadSubscript<char [6]>(YAML::Mark const&, char const (&) [6])':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h:264: undefined reference to `__imp__ZTVN4YAML12BadSubscriptE'
debug/_db.o: In function `YAML::detail::node& YAML::detail::node_data::convert_to_node<char [6]>(char const (&) [6], std::shared_ptr<YAML::detail::memory_holder>)':
C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h:229: undefined reference to `__imp__ZN4YAML6detail13memory_holder5mergeERS1_'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile.Debug:292: debug/test-twitter.exe] Error 1
make[1]: Leaving directory 'C:/Users/vagrant/twitter_offline_gui/test/gen'
make: *** [Makefile:45: debug] Error 2

I checked the libyaml-cpp.a file using nm, and it has these symbols but without the __imp_ prefix.

I also encountered this problem. Have you solved it? Can you tell me the solution

ihunzi avatar Jun 18 '22 02:06 ihunzi

Can you provide your full command line, and OS and version, etc.?

Hi, I meet the same issue. OS: Win10 version: newest command: mkdir build cd build cmake .. mingw32-make.exe No errors appears! But when I try to link the generated static library "libyaml-cppd.a" using another program and try to edit an Node ,the errors emerge.

Hi! I have the same problem. Do you have the solution now?

BoMingZhao avatar Jun 29 '22 08:06 BoMingZhao

Hi! I had the same issue in Windows 10 when trying to use the static library. It seems that the flag YAML_CPP_STATIC_DEFINE was lost at some point, so it was trying to call the shared library. In my case, I could solve it adding this before including the library:

#if WIN32
    #define YAML_CPP_STATIC_DEFINE
#endif
#include "yaml-cpp/yaml.h"

I hope it helps.

MariaRamos89 avatar Jul 24 '22 17:07 MariaRamos89

Hi! I had the same issue in Windows 10 when trying to use the static library. It seems that the flag YAML_CPP_STATIC_DEFINE was lost at some point, so it was trying to call the shared library. In my case, I could solve it adding this before including the library:

#if WIN32
    #define YAML_CPP_STATIC_DEFINE
#endif
#include "yaml-cpp/yaml.h"

I hope it helps.

Yup, this fixed it for me, thanks!

blagalucianflorin avatar Sep 04 '22 14:09 blagalucianflorin

Hi!

Just for information it works for me with 'MSYS Makefiles' under MSYS2.

  1. Before yaml-cpp make instructions, update cmake to 3.25.0 version:
pacman -R mingw-w64-x86_64-cmake # uninstall 3.23.2 in my case
pacman -S mingw-w64-x86_64-cmake # install last one cmake 3.25.0
  1. Then, mkdir ou place in a source folder of your choice, it Works fine building AMD64 binaries (lib/libyaml-cpp.a) following these instructions below :
    git clone https://github.com/jbeder/yaml-cpp.git
    mkdir build
    cd build
    
    cmake -G "MSYS Makefiles" ..
    make
    make install

make install [ 84%] Built target yaml-cpp [ 89%] Built target yaml-cpp-sandbox [ 94%] Built target yaml-cpp-parse [100%] Built target yaml-cpp-read Install the project...

-- Install configuration: "" -- Installing: C:/Program Files (x86)/YAML_CPP/lib/libyaml-cpp.a -- Installing: C:/Program Files (x86)/YAML_CPP/include -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/anchor.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/binary.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/contrib -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/contrib/anchordict.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/contrib/graphbuilder.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/depthguard.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/dll.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/emitfromevents.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/emitter.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/emitterdef.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/emittermanip.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/emitterstyle.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/eventhandler.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/exceptions.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/mark.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/convert.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/impl.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/iterator.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/iterator_fwd.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/memory.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_data.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_iterator.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/detail/node_ref.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/emit.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/impl.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/iterator.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/node.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/parse.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/ptr.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/node/type.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/noexcept.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/null.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/ostream_wrapper.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/parser.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/stlemitter.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/traits.h -- Installing: C:/Program Files (x86)/YAML_CPP/include/yaml-cpp/yaml.h -- Installing: C:/Program Files (x86)/YAML_CPP/lib/cmake/yaml-cpp/yaml-cpp-targets.cmake -- Installing: C:/Program Files (x86)/YAML_CPP/lib/cmake/yaml-cpp/yaml-cpp-targets-noconfig.cmake -- Installing: C:/Program Files (x86)/YAML_CPP/lib/cmake/yaml-cpp/yaml-cpp-config.cmake -- Installing: C:/Program Files (x86)/YAML_CPP/lib/cmake/yaml-cpp/yaml-cpp-config-version.cmake -- Installing: C:/Program Files (x86)/YAML_CPP/lib/pkgconfig/yaml-cpp.pc

Hope this help. Nicolas

niva-xx avatar Nov 27 '22 11:11 niva-xx

hi all,I meet the same problem on win10 gcc11 and cmake 3.14

WhyLogin avatar Dec 09 '22 03:12 WhyLogin