Operating System - Linux
1756543 Members
3216 Online
108848 Solutions
New Discussion юеВ

Re: /usr/ccs/bin/ld: server.cxx: Not a valid object file (invalid system id)

 
SOLVED
Go to solution
msbinu
Advisor

/usr/ccs/bin/ld: server.cxx: Not a valid object file (invalid system id)

Hi All,

I m trying to write a clinet -server program using openssl.I managed to compile openssl .But when I try to compile the server.cxx ( which I have created ) I m getting the following error

/usr/ccs/bin/ld: server.cxx: Not a valid object file (invalid system id)

Here is the command which I have used to compile the same

cc -I /home/myuserid/openssl-0.9.7-stable-SNAP-20060421/include -L . -lcrypto -lssl -o server server.cxx
Can anyone help me to get rid of this error

Regards
Binu
4 REPLIES 4
Mike Stroyan
Honored Contributor

Re: /usr/ccs/bin/ld: server.cxx: Not a valid object file (invalid system id)

You need aCC instead of cc for a C++ file like server.cxx. The cc compiler only handles C files. When it saw the server.cxx argument cc treated it like an object file and passed it on to the linker.
msbinu
Advisor

Re: /usr/ccs/bin/ld: server.cxx: Not a valid object file (invalid system id)

Thanx mike , but if I use aCC I will get the following error

aCC -I/home/myuserid/openssl-0.9.7-stable-SNAP-20060421/include -L . -lcrypto -lssl -o server server.cxx

Warning 749: "server.cxx", line 69 # The cast from 'sockaddr_in *' to 'sockaddr *' is performed as a
'reinterpret_cast'. This operation is non-portable and potentially unsafe.
bind(sd, (struct sockaddr*)&addr, sizeof(addr)); /* bind it */
^^^^^^^^^^^^^^^^^^
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (server.o) was detected. The linked output may not run on a PA 1.x system.
/usr/ccs/bin/ld: Unsatisfied symbols:
OPENSSL_add_all_algorithms_noconf (code)
SSL_accept (code)
SSL_set_fd (code)
SSL_new (code)
SSL_CTX_new (code)
SSL_get_fd (code)
cma_close (code)
SSL_write (code)
SSL_CTX_use_PrivateKey_file (code)
SSL_load_error_strings (code)
SSL_CTX_check_private_key (code)
SSLv2_server_method (code)
SSL_CTX_use_certificate_file (code)
cma_socket (code)
cma_accept (code)
SSL_read (code)
SSL_free (code)
Mike Stroyan
Honored Contributor
Solution

Re: /usr/ccs/bin/ld: server.cxx: Not a valid object file (invalid system id)

The warning about reinterpret_cast can be avoided by using an explicit reinterpret_cast like this-
bind(sd, reinterpret_cast(&addr), sizeof(addr));

The missing SSL_* symbols can be found by rearranging the compile line to put the source code before the libraries that provide those symbols-

aCC -I/home/myuserid/openssl-0.9.7-stable-SNAP-20060421/include server.cxx -L . -lcrypto -lssl -o server

The missing cma_* symbols indicate that you are using threading headers. It also indicates that you are using an old system that defaults to the user-space libcma threading instead of the current kernel libpthread threading. If you had a new enough aCC you could compile and link with -mt to get the right defines and libraries to use threads. You may have an old aCC that does not implement -mt. In that case you need to pass specific options for compiling files and for linking. Linking with -lcma will start to fix your threading problems. But you really need to get all the options right to avoid runtime problems.

Use "aCC -V" to see what version of aCC you have. Go to http://www.hp.com/go/c++ and the "Review documentation" link there to see the "Programmer's Guide" for your version of the compiler. Read the section on "Threads and Parallel Processing" from the guide.
msbinu
Advisor

Re: /usr/ccs/bin/ld: server.cxx: Not a valid object file (invalid system id)

Thanks a lot mike ..

It helped me a lot ...
Actually After trying your suggestion I was getting the following error ...

/usr/ccs/bin/ld: Unsatisfied symbols:
PEM_read_bio_X509 (code)
X509_STORE_get_by_subject (code)
EVP_enc_null (code)
X509_VERIFY_PARAM_set_purpose (code)
X509_VERIFY_PARAM_set_trust (code)
X509_STORE_CTX_init (code)
PEM_read_bio_RSAPrivateKey (code)
COMP_CTX_free (code)
OPENSSL_DIR_end (code)
BIO_f_buffer (code)
X509_STORE_CTX_get_ex_new_index (code)
X509_STORE_CTX_set_default (code)
X509_STORE_CTX_cleanup (code)
X509_STORE_set_default_paths (code)


After that I cnhanged the order of the library files ..
ie , lssl i gave first and then lcrypto .. then it worked :)

Thanks a lot

Regards
Binu