473,382 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Link time errors

Hi

I am trying to build a small client-server program using OpenSSL functions. I get errors on trying to build the program using Visual Studio .Net (Visual C++ 7.0). I am new to Visual Studio environment, pls bear with me if this one is a trivial question

Here's the procedure I followed

(1) Copied libeay32.lib and ssleay32.lib to C:\program files\Microsoft Visual Studio .NET\Vc7\li
(2) Copied the OpenSSL header files to c:\program files\MicrosoftVisual Studio .NET\Vc7\include\openssl folde

(3) On building the program, I get the following errors

SSL error LNK2019: unresolved external symbol _ERR_print_errors_fp referenced in function _handle_erro
SSL error LNK2019: unresolved external symbol _SSL_load_error_strings referenced in function _init_OpenSS
SSL error LNK2019: unresolved external symbol _SSL_library_init referenced in function _init_OpenSS
SSL error LNK2019: unresolved external symbol _THREAD_setup referenced in function _init_OpenSS
SSL error LNK2019: unresolved external symbol _BIO_read referenced in function _do_server_loo
SSL error LNK2019: unresolved external symbol _ERR_remove_state referenced in function _server_threa
SSL error LNK2019: unresolved external symbol _BIO_free referenced in function _server_threa
SSL error LNK2019: unresolved external symbol _BIO_pop referenced in function _mai
SSL error LNK2019: unresolved external symbol _BIO_ctrl referenced in function _mai
SSL error LNK2019: unresolved external symbol _BIO_new_accept referenced in function _mai
SSL fatal error LNK1120: 10 unresolved external

I understand that the tool is unable to obtain symbols for these SSL functions. Isn't it sufficient that I copy these libraries to the location specified in step (1) ? Would this suffice as it's in the standard path where Visual Studio should look for the library ? Am I overlooking some cruical aspect here

Any help in this regard would be much appreciated

Thanks
Krishnan

Here's the complete program

------------------------------------------------------------------------------
Server.c

#include "common.h

#define CERTFILE "server.pem
SSL_CTX *setup_server_ctx(void

SSL_CTX *ctx

ctx = SSL_CTX_new(SSLv23_method( ))
if (SSL_CTX_use_certificate_chain_file(ctx, CERTFILE) != 1
int_error("Error loading certificate from file")
if (SSL_CTX_use_PrivateKey_file(ctx, CERTFILE, SSL_FILETYPE_PEM
!= 1
int_error("Error loading private key from file")
return ctx
int do_server_loop(SSL *ssl

int err, nread
char buf[80]

d

for (nread = 0; nread < sizeof(buf); nread += err

err = SSL_read(ssl, buf + nread, sizeof(buf) - nread)
if (err <= 0
break

fprintf(stdout, "%s", buf)

while (err > 0)
return (SSL_get_shutdown(ssl) & SSL_RECEIVED_SHUTDOWN) ? 1 : 0
void THREAD_CC server_thread(void *arg

SSL *ssl = (SSL *)arg

#ifndef WIN3
pthread_detach(pthread_self( ))
#endi
if (SSL_accept(ssl) <= 0
int_error("Error accepting SSL connection")
fprintf(stderr, "SSL Connection opened\n")
if (do_server_loop(ssl)
SSL_shutdown(ssl)
els
SSL_clear(ssl)
fprintf(stderr, "SSL Connection closed\n")
SSL_free(ssl)

ERR_remove_state(0)

#ifdef WIN3
_endthread( )
#endi
int main(int argc, char *argv[]

BIO *acc, *client
SSL *ssl
SSL_CTX *ctx
THREAD_TYPE tid

init_OpenSSL( )
seed_prng( )

ctx = setup_server_ctx( )

acc = BIO_new_accept(PORT)
if (!acc
int_error("Error creating server socket")

if (BIO_do_accept(acc) <= 0
int_error("Error binding server socket")

for (;;

if (BIO_do_accept(acc) <= 0
int_error("Error accepting connection")

client = BIO_pop(acc)
if (!(ssl = SSL_new(ctx))
int_error("Error creating SSL context")

SSL_set_bio(ssl, client, client)
THREAD_CREATE(tid, (void *)server_thread, ssl)
}

SSL_CTX_free(ctx);
BIO_free(acc);
return 0;
}

--------------------------------------------------------------------------------

Common.h

#ifndef COMMON_H
#define COMMON_H

#include <string.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/ssl.h>
#include <openssl/x509v3.h>
#include "reentrant.h"

#ifndef WIN32
#include <pthread.h>
#define THREAD_CC
#define THREAD_TYPE pthread_t
#define THREAD_CREATE(tid, entry, arg) pthread_create(&(tid), NULL, (entry), (arg))
#else
#include <windows.h>
#define THREAD_CC __cdecl
#define THREAD_TYPE DWORD
#define THREAD_CREATE(tid, entry, arg) do { _beginthread((entry), 0,
(arg)); (tid) =
GetCurrentThreadId(); } while (0)
#endif

#define PORT "16001"
#define SERVER "localhost"
#define CLIENT "localhost"

#define int_error(msg) handle_error(__FILE__, __LINE__, msg)
void handle_error(const char *file, int lineno, const char *msg);

void init_OpenSSL(void);

int verify_callback(int ok, X509_STORE_CTX *store);

long post_connection_check(SSL *ssl, char *host);

void seed_prng(void);

#endif /* COMMON_H */

--------------------------------------------------------------------------------
Nov 17 '05 #1
0 1996

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mr X | last post by:
I am getting link errors and don't understand why: - ClientClass is in Project A - NoLinkCalledClass is in Project B - Project A depends on project B -...
10
by: Gary Hughes | last post by:
I'm getting the following error when attempting to link a managed C++ dll. I can't find any reference to these errors with google. Can anyone help? I've included the class definition causing the...
7
by: Kristof Thys via .NET 247 | last post by:
Post a new message to microsoft.public.dotnet.languages.vc http://www.dotnet247.com/247reference/default.aspx Hello, I've been struggling for weeks with this problem, I hope I find some...
1
by: noleander | last post by:
I need to use a library supplied by someone else: libjpeg.lib. This is a plain C library. I do not have the source code. I do have the header *.h files. When I run dumpbin on the libjpeg.lib,...
4
by: Mike Woinoski | last post by:
(I'm new to VS, so please forgive me if this is a faq.) I'm writing some Java web services and need to test them with C++ clients. I can use either a Windows Form application or an MFC application....
6
by: ermanu | last post by:
Hello we don't know much about C. But we have to resolve this problem in order to work on our project. We're getting below errors whenever we try to build the code. We're trying to build the code...
14
by: hgraham | last post by:
Hi, I'm trying to understand how to work the dom, and all I'm trying to do is insert a link right before another link in the html based on it's href value. This isn't a real world example - I'm...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
5
by: Bruce | last post by:
I am getting a lot of link errors when compiling in the debug build but not release. I am compiling a CLR managed code class library. I believe the link errors are actually being caused by a...
2
by: jbanik10 | last post by:
. What errors are caught at compile time vs link time?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.