From owner-freebsd-questions Sat Oct 14 8:45:17 2000 Delivered-To: freebsd-questions@freebsd.org Received: from distortion.dk (distortion.dk [195.249.147.156]) by hub.freebsd.org (Postfix) with ESMTP id E59D537B66D for ; Sat, 14 Oct 2000 08:45:13 -0700 (PDT) Received: from petri2000 ([194.192.131.97]) by distortion.dk (8.9.3/8.9.1) with SMTP id RAA53710 for ; Sat, 14 Oct 2000 17:49:25 +0200 (CEST) (envelope-from nppsecure@swamp.dk) Message-ID: <000701c035f6$47f66190$6732a8c0@atomic.dk> From: "Nicolai Petri" To: Subject: How to compile and link a lib for use with dlopen() ? Date: Sat, 14 Oct 2000 17:49:04 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I'm porting some software from Windows (I know it....) and it is using external dll's that's dynamic loaded with LoadModule() and GetProcAddr(). The Unix equivalent i think is dlopen() and dlsym(). My question is how to compile and link the following 2 pieces of code to make it work. The code is just out of the head written and just as an example... It can't compile, I've tried some different compiler settings... But 'nm' does not list my exported functions... ?? Please help. ----------- utility.cpp ----------- This should be in test.so.1 lib. #include class A { public: int GetValue(); void SetValue(int); }; extern "C" { A* GetNewA() /* This function I want exported */ { return new A; } }; ------ use.cpp ---------- #include typedef (A*)(EntryFunc*)(); int main() { int h = dlopen("test.so.1"); EntryFunc GetA=dlsym(h,"GetNewA"); A* test = GetA(); /* Do other stuff */ }; Thanx for any help you can give me :o). --- Nicolai Petri To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message