Im currently studying c++ from Bjarne Stroustrup PP and C textbook. Im using X code since Im using a Mac and that seems like the best option as an IDE. I Opened a new folder and copy/pasted his "std_lib_facilities" header file into the folder. When I work on an exercise I simple include the header file on top of my program and it seems to do the trick, however, if I then open another file in the same folder and do the same, both programs seem to fail on me. It seems to be some kind of linker issue. I just can't seem to figure this one out, if I close and open Xcode and reuse the original code it works, but once again fails if I try to open another C++ file and use the header. Any help would be greatly appreciated, as its a real pain to keep restarting Xcode, and having to use the same damn file for every exercise as you may imagine. Thank you in advance.
Asked
Active
Viewed 43 times
0
-
1How this fails , the complete error message given buy the compiler or linker, is very important to providing a good answer. – user4581301 Jul 09 '19 at 01:45
-
std_lib_facilities.h:104:14: Comparison of unsigned expression < 0 is always false and clang: error: linker command failed with exit code 1 (use -v to see invocation) Its as though it no longer includes the "std_lib_facilities.h" header file, although nothing had changed in the code at all, and it had previously worked. Thanks for the quick reply. – jack.b Jul 09 '19 at 01:57
-
1Comments are pretty small and bad at formatting. This is by design as anytime you need lots of text and fancy formatting you should either be [editing the question](https://stackoverflow.com/posts/56944108/edit) or making an answer. Editing the question is the right choice here. – user4581301 Jul 09 '19 at 02:00
-
1A linker error is not the direct consequence of an `#include`. `#include` copy/pastes declarations of the respective header into your C++ code file. Compiling this will work if the compiler can find the included file and it doesn't conflict with the rest of code. A linker error occurs if you used decls./defs. of that header but the linker cannot find the corresponding symbols anywhere. That means you need to add the resp. library (or object files) to the link command. IDEs usually provide a (project) option for that, something like "Add Library Paths" and "Add Libraries". – Scheff's Cat Jul 09 '19 at 06:18
-
Possible duplicate of [SO: What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/q/12573816/7478597). – Scheff's Cat Jul 09 '19 at 06:19
-
Can you include examples of the code you are using that causes this error? – zmike Jul 09 '19 at 18:53