Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I want to use Tensorflow shared object in my other C++ code, named as Temp_TF.cc
I am using the following command to create an executable.
g++ ../../../bazel-bin/tensorflow/cc/example/Temp_TF.so -ltensorflow_cc Temp_TF.cc -o Temp_TF
What is wrong with the following command?
I am getting the following error:
Temp_TF.cc:3:49: fatal error: tensorflow/cc/client/client_session.h: No such file or directory
compilation terminated.
I can see you're new to Stack Overflow.
Technically your question does not have enough data for us to provide an answer for sure.
However it looks to me as though you're missing a -I (capital i) directive and the compiler does not know where to find the tensorflow/cc/client/client_session.h path.
From the look of it, you could try:
g++ -I ../../../bazel-bin ../../../bazel-bin/tensorflow/cc/example/Temp_TF.so -ltensorflow_cc Temp_TF.cc -o Temp_TF
(note the -I)
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
i have these files:-
/lib
kernel.hpp
kernel.cpp
main.cpp
when i use
gcc -m32 -c main.cpp -lstdc++ -o main.o -llib/kernel.hpp
it says
[function name]([type of argument 1], [type of argument 2]) is not declared in this scope
how to fix?
I started writing a comment, but got to be too long, so we'll make it an answer instead. I don't think it in fact will answer your question, but it may point you in the right direction.
Let's clear up a misconception, c++ is not a superset of c; there are c constructs that c++ does not support. If your code is c++, you need to compile it with a c++ compiler. The problems you've been describing all indicate that compilation is failing; you're not at the point where the linker is involved. The compile command you provided in your question had a -c flag, which tells the compiler to stop after the compilation step - so there's no point in having a -lstd++ flag in addition. For the compiler to find kernel.hpp you need a -I flag which indicates the directory where kernel.hpp can be found. That's what I was suggesting in my first comment.
To sum up, as shown in the original question, you're using the wrong compiler and the wrong flags for what you want to do.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I've just written the following into the console:
g++ -o main.cpp main
and my main.cpp is gone.
Did I just lose my 3 hours of work?
Yes, you did. The -o flag specifies the output file (main.cpp in your case since that's the file name immediately following it):
g++ -o main.cpp main
\_________/ \__/
\ \_This is the input file.
\_____This specifies the output file.
In other words, you have told the compiler to try and compile what would normally be your executable, and write the results to your source file (overwriting it). A more suitable command would have been:
g++ -o main main.cpp
This is one of those educating moments that developers experience from time to time (including old hacks like me), the sort of thing that should convince you to do regular commits to git (or other source control system), or compile code with a build system rather than possibly complex command lines.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
__FILE__ is returning me the complete file path when I run the program in 32 bit.
But in 64 bit it is giving only the file name. How to resolve this?
That depends probably more on the way you drive your compiler than a 32/64 bits difference.
My expectation (and what I verified just here with gcc) is that __FILE__ gives the name as provided to the compiler. For instance
$ cat foo.c
int main() { printf("%s\n",__FILE__); }
$ gcc foo.c & ./a.out
foo.c
$ gcc ./foo.c & ./a.out
./foo.c
$ gcc `pwd`/foo.c & ./a.out
/the/full/path/as/reported/by/pwd/foo.c
similarly for include files, the path reported is the one used by the compiler to access the header, thus may depend on the way you specified the include directories.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
there is one so, the so contain one cpp. the cpp's includes:
include "openssl/evp.h"
OpenSSL_add_all_digests()
nm the so ,and see the symbol as U:
U OpenSSL_add_all_digests
thus I check the so' Makefile,it doesn't contain lib:libssl(-L -lssl) in makefile, but it can make so successfully.
but when I write one cpp to link the so and test it, If I doesn't link the libssl with test cpp, it will popup "undefined reference" error.
How to understand it?
Generating so does NOT require all symbols to be resolved;
Generating executable requires all symbols to be resolved.
So if you generate a so, you can have "undefined reference", e.g.
testso.cpp:
void funcA();
void funcB()
{
funcA();
}
And compile and link like below:
g++ -fPIC -o testso.o -c testso.cpp # COmpile
g++ testso.o -shared -o libtestso.so # Link
You can generate libtestso.so successfully.
But if you try to link it to an executable, you need to have funcA() defined.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm fairly comfortable with Linux and compiling things - I normally just follow the instructions and can manage to get myself out of trouble. This time, I was given a .cpp file by a random Internet citizen and I would really like to know how to compile it. Everything I seem to try (g++, c++, gcc) doesn't seem to work.
Anyhow, here's the file: http://pastebin.ca/2073013
Edit: Updated with verbose output from g++ file.cpp -o whatever: http://pastebin.ca/2073052
You'll need to compile it using:
g++ inputfile.cpp -o outputbinary
The file you are referring has a missing #include <cstdlib> directive, if you also include that in your file, everything shall compile fine.
The compiler is telling you that there are problems starting at line 122 in the middle of that strange FBI-CIA warning message. That message is not valid C++ code and is NOT commented out so of course it will cause compiler errors. Try removing that entire message.
Also, I agree with In silico: you should always tell us what you tried and exactly what error messages you got.
Just type the code and save it in .cpp format. then try "gcc filename.cpp" . This will create the object file. then try "./a.out" (This is the default object file name). If you want to know about gcc you can always try "man gcc"