i am trying to make a simple tcp connection without authentication, for starters, using the openssl library( i can use winsock but its hard to use for authentication so am trying out openssl).
i realised that the following are required for using the openssl library(correct me if am wrong so that we are on the same foot here)
1. an installation of the library (for example i downloaded mine as a package from devpaks.org)
2.linking the project to libeay to avoid linker errors.
all set, i was surprised when the code bellow did not work. the only error displayed was
" F:\deo\deo\Makefile.win [Build Error][Project1.exe] Error 1 "
what does this error mean and how can it be corrected.
some data you may find useful
1. operating system : microsoft windows xp service pack 2
2. compiler: devc++ bloodshed version 4.9.9.2
source code
//openssl related libraries
include "openssl/ssl.h"
include "openssl/bio.h"
include "openssl/err.h"
//and other libraries
include "cstdio"
include "cstring"
//remember to link the project to libeay library
//under "project" > "project options" > parameters > linker
//the above was our http request. it consists of GET /path_to_file HTTP_PROTOCOL_VERSION //then other headers. the "host" header is necessary for http 1.1 requests. each line is separated
//a carriage return, linefeed pair which are encoded above in hexadecimal ie \r\n is equivalent to // \x0D\X0A
> what does this error mean and how can it be corrected.
It means only that the build failed (i.e. a command issued by make returned an non-zero errorlevel). The reason for this will usually be indicated in earlier in the compile log (where the execution of the failing command is shown), which is why you should always post the entire "Compile Log" text. Even if the command issues no message itself, we will at least be able to determine what teh comand was and how it was invoked.
If you are not looking at the "Compile Log" tab, you should be - not the "Compiler" tab - that filters the log, and only shows messages that ar in the expected format for compiler, pre-processor, and linker messages - that is not the only thing that could fail.
The log also shows us exactly how the code was really built, rather than you describing it, and us taking your word for it. Accurate and simple, and less typing for you.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
main.o(.text+0x4c):main.cpp: undefined reference to `SSL_load_error_strings'
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
Since the error was being caused by this SSL_load_error_strings', i simply deleted it and the project compiled fine.
thanks alot. But for the sake of curiosity, is there a way to bypass the error without deletingSSL_load_error_strings' function?
trueleowdeo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you specify a -l option for a file that does not exist it will be ignored, so my guess is that either there is no file C:/Dev-Cpp/lib/libeay32.a, or if there is then it is not the one that contains SSL_load_error_strings.
Use the nm.exe tool in c:\dev-cpp\bin to list the symbols in an archive:
c:\dev-cpp\bin\nm -g libeay32.a
The documentation does not help, but from its name, I would guess that you also need ot link libssl32.a (-lssl32). You could use nm to check:
c:\dev-cpp\bin\nm -g libssl32.a
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
my project worked out perfectly. Thanks for the posts. this i learnt the following.
1. that a library called libxxx.a is linked by using -lxxx.
2. the two libraries i linked to the project are libeay32.a and libssl32.a
ie (-leay32 and -lssl32)
3. that i had to post the entire compile log :)
4. to run the final executable file , i found that libeay32.dll and libssl32.dll
had to be in the same directory as the executable
trueleowdeo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> 4. to run the final executable file , i found that libeay32.dll
> and libssl32.dll had to be in the same directory as the
> executable
Not entirely true. They have to either be in the same folder as the executable or in a path specified in the PATH environment variable, which is used by the OS as a search list for executable files and DLLs.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is the compile log. Ok it seems to say that 'libeay' doesnot exist . thanks thats one step closer to the solution. probably i linked with the wrong library . What is the correct library you link with in openssl?
The log, the whole log and nothing but the log! Simply Copy & paste the text as is, no omissions! (right click in the "Compiler Log" window to copy all the text.
As it happens in this case you have probably provided sufficient information, (but there may be other problems we could have spotted that you have hidden from us). Generally if you have a problem you are asking about, almost by definition you are not in a position to determine the required information, so post it all, it is at zero cost to yourself to do so.
You need -leay not libeay as the option.
The -l<xxx> option causes the linker to search for lib<xxx>.a in any of the paths specified by preceeding -L<path> options. You only have one of those, so -leay will look for C:/Dev-Cpp/lib/libeay.a. Personally I think it is a bad idea to put third-party libraries in the basic tool-chain installation, and would place the library elsewhere and add an additional library directory. However it is probable that that is where the DevPak placed it.
Alternatively you could place the fully qualified path in the command line 9that is what tje "add object file or library" browse button does, but just specifying libeay, will look for a file of exactly that name (no extension) in the project directory.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i am trying to make a simple tcp connection without authentication, for starters, using the openssl library( i can use winsock but its hard to use for authentication so am trying out openssl).
i realised that the following are required for using the openssl library(correct me if am wrong so that we are on the same foot here)
1. an installation of the library (for example i downloaded mine as a package from devpaks.org)
2.linking the project to libeay to avoid linker errors.
all set, i was surprised when the code bellow did not work. the only error displayed was
" F:\deo\deo\Makefile.win [Build Error] [Project1.exe] Error 1 "
what does this error mean and how can it be corrected.
some data you may find useful
1. operating system : microsoft windows xp service pack 2
2. compiler: devc++ bloodshed version 4.9.9.2
source code
//openssl related libraries
include "openssl/ssl.h"
include "openssl/bio.h"
include "openssl/err.h"
//and other libraries
include "cstdio"
include "cstring"
//remember to link the project to libeay library
//under "project" > "project options" > parameters > linker
using namespace std;
int main()
{
BIO * bio;
int p;
//the above was our http request. it consists of GET /path_to_file HTTP_PROTOCOL_VERSION //then other headers. the "host" header is necessary for http 1.1 requests. each line is separated
//a carriage return, linefeed pair which are encoded above in hexadecimal ie \r\n is equivalent to // \x0D\X0A
}
//thank you for even bothering to read to the end of the project. waiting to hear what you think
> what does this error mean and how can it be corrected.
It means only that the build failed (i.e. a command issued by make returned an non-zero errorlevel). The reason for this will usually be indicated in earlier in the compile log (where the execution of the failing command is shown), which is why you should always post the entire "Compile Log" text. Even if the command issues no message itself, we will at least be able to determine what teh comand was and how it was invoked.
If you are not looking at the "Compile Log" tab, you should be - not the "Compiler" tab - that filters the log, and only shows messages that ar in the expected format for compiler, pre-processor, and linker messages - that is not the only thing that could fail.
The log also shows us exactly how the code was really built, rather than you describing it, and us taking your word for it. Accurate and simple, and less typing for you.
Clifford
"Mechanically, how did you try to do the link?"
In the menu bar chose "project" >"project options" >"parameters">"linker"
then simply typed "libeay"
You do realize that the command for linking a library contained in a file called (for example)
libxyz.a
is of the form
-lxyz
where that is a small L
Wayne
Thanks but am curious....
Linking with -leay produced this compile log;
compile log
Compiler: Default compiler
Building Makefile: "F:\deo\deo\Makefile.win"
Executing make...
make.exe -f "F:\deo\deo\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
g++.exe main.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" -leay32
main.o(.text+0x4c):main.cpp: undefined reference to `SSL_load_error_strings'
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
Since the error was being caused by this
SSL_load_error_strings', i simply deleted it and the project compiled fine. thanks alot. But for the sake of curiosity, is there a way to bypass the error without deleting
SSL_load_error_strings' function?trueleowdeo
If you specify a -l option for a file that does not exist it will be ignored, so my guess is that either there is no file C:/Dev-Cpp/lib/libeay32.a, or if there is then it is not the one that contains SSL_load_error_strings.
Use the nm.exe tool in c:\dev-cpp\bin to list the symbols in an archive:
c:\dev-cpp\bin\nm -g libeay32.a
The documentation does not help, but from its name, I would guess that you also need ot link libssl32.a (-lssl32). You could use nm to check:
c:\dev-cpp\bin\nm -g libssl32.a
Clifford
my project worked out perfectly. Thanks for the posts. this i learnt the following.
1. that a library called libxxx.a is linked by using -lxxx.
2. the two libraries i linked to the project are libeay32.a and libssl32.a
ie (-leay32 and -lssl32)
3. that i had to post the entire compile log :)
4. to run the final executable file , i found that libeay32.dll and libssl32.dll
had to be in the same directory as the executable
trueleowdeo
Thanks, a summary is always useful.
> 4. to run the final executable file , i found that libeay32.dll
> and libssl32.dll had to be in the same directory as the
> executable
Not entirely true. They have to either be in the same folder as the executable or in a path specified in the PATH environment variable, which is used by the OS as a search list for executable files and DLLs.
Clifford
Here is the compile log. Ok it seems to say that 'libeay' doesnot exist . thanks thats one step closer to the solution. probably i linked with the wrong library . What is the correct library you link with in openssl?
compile log
g++.exe main.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" libeay
g++.exe: libeay: No such file or directory
make.exe: *** [Project1.exe] Error 1
Execution terminated
"g++.exe main.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" libeay "
Mechanically, how did you try to do the link?
Wayne
The log, the whole log and nothing but the log! Simply Copy & paste the text as is, no omissions! (right click in the "Compiler Log" window to copy all the text.
As it happens in this case you have probably provided sufficient information, (but there may be other problems we could have spotted that you have hidden from us). Generally if you have a problem you are asking about, almost by definition you are not in a position to determine the required information, so post it all, it is at zero cost to yourself to do so.
You need -leay not libeay as the option.
The -l<xxx> option causes the linker to search for lib<xxx>.a in any of the paths specified by preceeding -L<path> options. You only have one of those, so -leay will look for C:/Dev-Cpp/lib/libeay.a. Personally I think it is a bad idea to put third-party libraries in the basic tool-chain installation, and would place the library elsewhere and add an additional library directory. However it is probable that that is where the DevPak placed it.
Alternatively you could place the fully qualified path in the command line 9that is what tje "add object file or library" browse button does, but just specifying libeay, will look for a file of exactly that name (no extension) in the project directory.
Clifford