Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot compile 0.10.7 with uClibc++ #1158

Open
neheb opened this issue Apr 15, 2020 · 4 comments
Open

cannot compile 0.10.7 with uClibc++ #1158

neheb opened this issue Apr 15, 2020 · 4 comments

Comments

@neheb
Copy link
Contributor

neheb commented Apr 15, 2020

Describe the bug

/home/mangix/devstuff/openwrt/staging_dir/toolchain-mips_24kc_gcc-9.3.0_musl/lib/gcc/mips-openwrt-linux-musl/9.3.0/../../../../mips-openwrt-linux-musl/bin/ld: src/lib_json/libjsoncpp.a(json_value.cpp.o): in function `Json::Value::operator<(Json::Value const&) const':
json_value.cpp:(.text+0x5dc): undefined reference to `bool std::operator< <Json::Value::CZString, Json::Value, std::less<Json::Value::CZString>, std::allocator<Json::Value> >(std::map<Json::Value::CZString, Json::Value, std::less<Json::Value::CZString>, std::allocator<Json::Value> > const&, std::map<Json::Value::CZString, Json::Value, std::less<Json::Value::CZString>, std::allocator<Json::Value> > const&)'
collect2: error: ld returned 1 exit status

This was after several changes with defines to get it to build. Also backported b082693

Maybe something else is needed...

Desktop (please complete the following information):

  • OS: OpenWrt
  • Meson version - latest. 0.54
  • Ninja version - latest 1.10
@neheb
Copy link
Contributor Author

neheb commented Apr 15, 2020

Real error:

src/lib_json/json_value.cpp:937:16: warning: returning reference to temporary [-Wreturn-local-addr]
  937 |   return (*it).second;
      |          ~~~~~~^~~~~~
src/lib_json/json_value.cpp: In member function 'const Json::Value* Json::Value::find(const char*, const char*) const':
src/lib_json/json_value.cpp:1010:17: error: taking address of rvalue [-fpermissive]
 1010 |   return &(*it).second;

I tried to work around it by using normal iterators but that didn't work.

@BillyDonahue
Copy link
Contributor

BillyDonahue commented Apr 15, 2020

For reference (fudging the line number a bit):

src/lib_json/json_value.cpp:937

return (*it).second;

and

src/lib_json/json_value.cpp:1010

return &(*it).second;

@BillyDonahue
Copy link
Contributor

BillyDonahue commented Apr 15, 2020

json_value.cpp:(.text+0x5dc): undefined reference to
bool std::operator< <K,V,C,A> (
    std::map<K,V,C,A> const &,
    std::map<K,V,C,A> const &);
[ with
  K = Json::Value::CZString,
  V = Json::Value,
  C = std::less<Json::Value::CZString>,
  A = std::allocator<Json::Value>
]

It should be the standard library's job to define the operator< between std::map objects.
Check your link line?

I don't see how the "real error" cited would contribute to a link error like this.

As far as I can tell, I don't think those return statements are returning local memory.
It may be that the version of jsoncpp this is happening on is not current master branch?

@neheb
Copy link
Contributor Author

neheb commented Apr 15, 2020

The way I got that link error was by changing two const_iterator to iterator. Otherwise I get those two return errors.

The version is the release version. Version 1.9.2 does not even compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants