Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Build Failing on OSX #72

Closed
Colin747 opened this issue Jan 5, 2017 · 13 comments
Closed

Build Failing on OSX #72

Colin747 opened this issue Jan 5, 2017 · 13 comments
Labels

Comments

@Colin747
Copy link

Colin747 commented Jan 5, 2017

Apologies if this is not a suitable place to pose such a question but I am having trouble building it for Java on OSX.

I'm using the following cmake command:

cmake .. -DBUILDJAVA=ON-std=c++11-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

However this is resulting in the following error when I run make:

[  3%] Building CXX object src/CMakeFiles/tinyb.dir/BluetoothObject.cpp.o
In file included from /Users/colinshewell/Downloads/tinyb-master/src/BluetoothObject.cpp:25:
/Users/colinshewell/Downloads/tinyb-master/api/tinyb/BluetoothObject.hpp:80:24: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
    static std::string java_class() {
                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
In file included from /Users/colinshewell/Downloads/tinyb-master/src/BluetoothObject.cpp:25:
/Users/colinshewell/Downloads/tinyb-master/api/tinyb/BluetoothObject.hpp:81:16: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
        return std::string(JAVA_PACKAGE "/BluetoothObject");
               ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
/Users/colinshewell/Downloads/tinyb-master/src/BluetoothObject.cpp:30:30: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
std::string BluetoothObject::get_java_class() const
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
/Users/colinshewell/Downloads/tinyb-master/src/BluetoothObject.cpp:32:11: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
   return std::string(JAVA_PACKAGE "/BluetoothObject");
          ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
/Users/colinshewell/Downloads/tinyb-master/src/BluetoothObject.cpp:35:30: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
std::string BluetoothObject::get_class_name() const
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
/Users/colinshewell/Downloads/tinyb-master/src/BluetoothObject.cpp:37:11: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
   return std::string("BluetoothObject");
          ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
/Users/colinshewell/Downloads/tinyb-master/src/BluetoothObject.cpp:40:30: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
std::string BluetoothObject::get_object_path() const
                             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
/Users/colinshewell/Downloads/tinyb-master/src/BluetoothObject.cpp:42:11: error: implicit
      instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
   return std::string();
          ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: 
      template is declared here
    class _LIBCPP_TYPE_VIS_ONLY basic_string;
                                ^
8 errors generated.
make[2]: *** [src/CMakeFiles/tinyb.dir/BluetoothObject.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/tinyb.dir/all] Error 2
make: *** [all] Error 2
@vkolotov
Copy link
Contributor

vkolotov commented Jan 5, 2017

Hi @Colin747, I think I had the same issue. I believe I got rid of it by specifying JAVA_HOME env variable:

export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt

@Colin747
Copy link
Author

Colin747 commented Jan 6, 2017

Thanks for your reply. I tried running your command but the build still failed at the same point.

@vkolotov
Copy link
Contributor

vkolotov commented Jan 6, 2017

Make sure you use a correct path to Java :)

@Colin747
Copy link
Author

Colin747 commented Jan 6, 2017

I tried setting it to:

export JAVA_HOME=$(/usr/libexec/java_home)

but this did not work either, is it the path to the Java SDK I need to set?

@petreeftime
Copy link
Collaborator

The cmake command you copied here seems to have some typos, there are missing spaces between some of the options. Can you add them and re-run make?
cmake .. -DBUILDJAVA=ON -std=c++11 -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

@Colin747
Copy link
Author

Colin747 commented Jan 8, 2017

When I run your command I get an error: CMake Error: The source directory "/tinyb-master/build/-std=c++11" does not exist.

If I remove the -std=c++11 then I get the same error as my original post.

@gustavo84
Copy link

gustavo84 commented Feb 9, 2017

I've tried compiling it and the same error has happened to me. Could you advise me about it. Please, thanks

@petreeftime
Copy link
Collaborator

The correct command is cmake -DBUILDJAVA=ON -std=c++11 -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ .., make sure there is a space before every -. Please note, that you would execute this command in tinyb/build folder. Also, you will need pkg-config and glib installed. I am not sure the compiled library will actually work.

@mingfai
Copy link

mingfai commented Mar 5, 2017

on my Mac OS X 10.11, with cmake 3.7.2, -std=c++11 won't work as cmake view the parameter as path, result as:
CMake Error: The source directory "$PROJECT_DIR/build/-std=c++11" does not exist.
And I have to use:

export CMAKE_CXX_STANDARD=11
#OR export CMAKE_CXX_FLAGS=-std=c++11
cmake .. -DBUILDJAVA=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++

then, cmake results as the following warning:
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
and that can be fixed with installing doxygen:
sudo port install doxygen

build I still encounter as the same problem in make as same as #84

p.s. in my research, I noticed there is also an option "-stdlib=libc++" and I'm not sure if it is relevant. so I tried using export CMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" as well.

reference:

@adamdossa
Copy link

Same process as above, same error (Mac OSX 10.12.3, cmake version 3.7.2):
export CMAKE_CXX_FLAGS=-std=c++11
#this generates no errors
cmake .. -DBUILDJAVA=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++
#this generates error
make
Generating JNI headers..
[ 6%] Built target tinybjar
[ 8%] Building CXX object src/CMakeFiles/tinyb.dir/BluetoothObject.cpp.o
In file included from /Users/adamdossa/Development/tinyb/src/BluetoothObject.cpp:25:
/Users/adamdossa/Development/tinyb/api/tinyb/BluetoothObject.hpp:80:24: error: implicit instantiation of
undefined template 'std::__1::basic_string<char, std::__1::char_traits,
std::__1::allocator >'
static std::string java_class() {
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:193:33: note: template is declared
here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
In file included from /Users/adamdossa/Development/tinyb/src/BluetoothObject.cpp:25:
/Users/adamdossa/Development/tinyb/api/tinyb/BluetoothObject.hpp:81:16: error: implicit instantiation of
undefined template 'std::__1::basic_string<char, std::__1::char_traits,
std::__1::allocator >'
return std::string(JAVA_PACKAGE "/BluetoothObject");
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:193:33: note: template is declared
here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/adamdossa/Development/tinyb/src/BluetoothObject.cpp:30:30: error: implicit instantiation of
undefined template 'std::__1::basic_string<char, std::__1::char_traits,
std::__1::allocator >'
std::string BluetoothObject::get_java_class() const
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:193:33: note: template is declared
here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/adamdossa/Development/tinyb/src/BluetoothObject.cpp:32:11: error: implicit instantiation of
undefined template 'std::__1::basic_string<char, std::__1::char_traits,
std::__1::allocator >'
return std::string(JAVA_PACKAGE "/BluetoothObject");
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:193:33: note: template is declared
here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/adamdossa/Development/tinyb/src/BluetoothObject.cpp:35:30: error: implicit instantiation of
undefined template 'std::__1::basic_string<char, std::__1::char_traits,
std::__1::allocator >'
std::string BluetoothObject::get_class_name() const
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:193:33: note: template is declared
here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/adamdossa/Development/tinyb/src/BluetoothObject.cpp:37:11: error: implicit instantiation of
undefined template 'std::__1::basic_string<char, std::__1::char_traits,
std::__1::allocator >'
return std::string("BluetoothObject");
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:193:33: note: template is declared
here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/adamdossa/Development/tinyb/src/BluetoothObject.cpp:40:30: error: implicit instantiation of
undefined template 'std::__1::basic_string<char, std::__1::char_traits,
std::__1::allocator >'
std::string BluetoothObject::get_object_path() const
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:193:33: note: template is declared
here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/adamdossa/Development/tinyb/src/BluetoothObject.cpp:42:11: error: implicit instantiation of
undefined template 'std::__1::basic_string<char, std::__1::char_traits,
std::__1::allocator >'
return std::string();
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:193:33: note: template is declared
here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
8 errors generated.
make[2]: *** [src/CMakeFiles/tinyb.dir/BluetoothObject.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/tinyb.dir/all] Error 2
make: *** [all] Error 2

@adamdossa
Copy link

For anyone following this thread, the following seems to be the solution:

In tinyb/api/tinyb/BluetoothObject.hpp add:
#include
#include
#include
Once I'd done the above, it compiled, but failed with a linking error:
[ 32%] Linking CXX shared library libtinyb.dylib
ld: library not found for -lintl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/libtinyb.0.5.0-8-g6e580f4.0.5.0-8-g6e580f4.0.5.0-8-g6e580f4.dylib] Error 1
make[1]: *** [src/CMakeFiles/tinyb.dir/all] Error 2
make: *** [all] Error 2

Fixing the above required forcing the symlinking of gettext which contains the intl library:
brew install gettext
brew link --force gettext

@adamdossa
Copy link

I've now trying to execute the example code:
java -cp /usr/local/lib/../lib/java/tinyb.jar:examples/java/HelloTinyB.jar -Djava.library.path=/usr/local/lib/ HelloTinyB xxx

But I get the error:
Exception in thread "main" java.lang.RuntimeException: Error getting object manager client: Could not connect: No such file or directory
at tinyb.BluetoothManager.init(Native Method)
at tinyb.BluetoothManager.(BluetoothManager.java:207)
at tinyb.BluetoothManager.getBluetoothManager(BluetoothManager.java:217)
at HelloTinyB.main(HelloTinyB.java:109)

[I use the MAC address of my BT device above]

Not sure if it is related to needing the BlueZ + GATT stack which is maybe not possible in Mac OSX which has its own stack?

@lightsing
Copy link

In file included from /Users/lightsing/Downloads/tinyb-0.5.0/src/BluetoothObject.cpp:25:
/Users/lightsing/Downloads/tinyb-0.5.0/api/tinyb/BluetoothObject.hpp:79:24: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
static std::string java_class() {
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: template
is declared here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
In file included from /Users/lightsing/Downloads/tinyb-0.5.0/src/BluetoothObject.cpp:25:
/Users/lightsing/Downloads/tinyb-0.5.0/api/tinyb/BluetoothObject.hpp:80:16: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
return std::string(JAVA_PACKAGE "/BluetoothObject");
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: template
is declared here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/lightsing/Downloads/tinyb-0.5.0/src/BluetoothObject.cpp:30:30: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
std::string BluetoothObject::get_java_class() const
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: template
is declared here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/lightsing/Downloads/tinyb-0.5.0/src/BluetoothObject.cpp:32:11: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
return std::string(JAVA_PACKAGE "/BluetoothObject");
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: template
is declared here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/lightsing/Downloads/tinyb-0.5.0/src/BluetoothObject.cpp:35:30: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
std::string BluetoothObject::get_class_name() const
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: template
is declared here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/lightsing/Downloads/tinyb-0.5.0/src/BluetoothObject.cpp:37:11: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
return std::string("BluetoothObject");
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: template
is declared here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/lightsing/Downloads/tinyb-0.5.0/src/BluetoothObject.cpp:40:30: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
std::string BluetoothObject::get_object_path() const
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: template
is declared here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
/Users/lightsing/Downloads/tinyb-0.5.0/src/BluetoothObject.cpp:42:11: error: implicit instantiation of undefined template
'std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >'
return std::string();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:193:33: note: template
is declared here
class _LIBCPP_TYPE_VIS_ONLY basic_string;
^
8 errors generated.
make[2]: *** [src/CMakeFiles/tinyb.dir/BluetoothObject.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/tinyb.dir/all] Error 2
make: *** [all] Error 2

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

No branches or pull requests

7 participants