Hi, cannot include iostream while developing a node. Do you, guys, know what may be a problem? I googled around and I see that this "iostream" is a little tricky – for example, there is no such header in newest Xcode.

I'm trying to include iostream in simple stateless node. My goal is to develop a node capturing output from system command. Look what I've found here: https://www.jeremymorgan.com/tutorials/c-programming/how-to-capture-the-...

11:57:12: Running steps for project dumski.data...
11:57:12: Configuration unchanged, skipping qmake step.
11:57:12: Starting: "/usr/bin/make" 
~/Developer/SDKs/vuo-1.2.8-sdk/framework/vuo-compile --verbose --header-search-path ~/Developer/SDKs/vuo-1.2.8-sdk/framework/Headers --output dumski.data.system.cmd.vuonode dumski.data.system.cmd.c
Module (node class, type, library) search paths:
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Modules
 /Library/Application Support/Vuo/Modules
 /Users/dumski/Library/Application Support/Vuo/Modules
 /Users/dumski/Library/Caches/org.vuo/1.2.8.86/Modules
Header search paths:
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Headers/
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Headers/macos
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Headers
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/Headers
Other library search paths:
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Modules
 /Library/Application Support/Vuo/Modules
 /Users/dumski/Library/Application Support/Vuo/Modules
Other framework search paths:
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Modules/
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Frameworks/
Framework path:
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework
Clang path:
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Frameworks/llvm.framework/Versions/A/Helpers/clang
clang -cc1 version 3.2 based upon LLVM 3.2svn default target x86_64-apple-darwin17.7.0
ignoring nonexistent directory "/Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/Headers"
ignoring duplicate directory "/Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Headers"
#include "..." search starts here:
#include <...> search starts here:
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Headers
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Headers/macos
 /usr/local/include
 /Users/dumski/Developer/SDKs/vuo-1.2.8-sdk/framework/./Vuo.framework/Frameworks/llvm.framework/Versions/A/lib/clang/3.2/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
dumski.data.system.cmd.c:2:10: fatal error: 'iostream' file not found
#include <iostream>
         ^
1 error generated.
dumski.data.system.cmd.c: error: Broken node — The node <code>dumski.data.system.cmd</code> couldn't be compiled to bitcode.  Check the macOS Console for details.

make: *** [dumski.data.system.cmd.vuonode] Error 1
11:57:12: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project dumski.data (kit: Desktop Qt 5.9.5 clang 64bit)
When executing step "Make"
11:57:12: Elapsed time: 00:00.

Comments

Thanks, Jaymie for the answer

dumski's picture
Submitted by

Thanks, Jaymie for the answer. Unfortunately, even taking example of "vuoize" stateless node (which of course compiles ok when not edited) and changing extension to .cc and including iostream causes same error:

17:48:26: Running steps for project example.stateless...
17:48:26: Configuration unchanged, skipping qmake step.
17:48:26: Starting: "/usr/bin/make" 
/Users/dumski/Qt/5.9.5/clang_64/bin/qmake -o Makefile example.stateless.pro -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
../../../framework/vuo-compile --output example.stateless.vuoize.vuonode example.stateless.vuoize.cc && mkdir -p ~/Library/Application\ Support/Vuo/Modules && cp example.stateless.vuoize.vuonode ~/Library/Application\ Support/Vuo/Modules
example.stateless.vuoize.cc:11:10: fatal error: 'iostream' file not found
#include <iostream>
         ^
1 error generated.
example.stateless.vuoize.cc: error: Broken node — The node <code>example.stateless.vuoize</code> couldn't be compiled to bitcode.  Check the macOS Console for details.

make: *** [example.stateless.vuoize.vuonode] Error 1
17:48:26: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project example.stateless (kit: Desktop Qt 5.9.5 clang 64bit)
When executing step "Make"
17:48:26: Elapsed time: 00:01.

Also, passing path to Xcode's iostream with --header-search-path sometimes work, but a lot of other errors appear.

I googled whole day and cannot make it compile. I read that adding -stdlib=libstdc++ flag can tell compiler explicitly to use standard C++ library, but adding this option to vuo-compile causes "unrecognized option" error. I even don't understand what is the role of vuo-compile while developing a node? Is it some kind of "host" which redirects compilation to other compiler, or it's compiler itself? Because CMake outputs only command starting vuo-compile and I wondered if vuo-compile passes a compilation somwhere else, or does some "quiet" compilation using clang/clang++?

Can you explain the process of compiling a node?

Thank you, Teo

Hmm, we tested the same thing

jstrecker's picture
Submitted by

Hmm, we tested the same thing (renamed to example.stateless.vuoize.cc and added #include <iostream>) and it worked OK.

Maybe you're missing the C++ standard headers. Do you have both Xcode and the Xcode Command Line Tools installed? One of those provides the headers, offhand I don't know which.

Or here is an alternative implementation in C.

Can you explain the process

jstrecker's picture
Submitted by

Can you explain the process of compiling a node?

  • First, vuo-compile invokes Clang to convert the .c or .cc file to an LLVM module. It passes along the header search paths from the vuo-compile arguments and adds a few additional arguments.
  • Then, it alters the LLVM module, renaming global variables and functions so that they are unique to the node class. For example, nodeEvent would be renamed to example_stateless_vuoize__nodeEvent.
  • Finally, it saves the altered LLVM module to file.