473,585 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

having main in shared library

I have created a shared library with main() .Still it is compiled and
loaded during invocation. Below is the code and build file.

sample_test.cpp
int test_method(Cfg ChkSession &s)
{
cout<<"working" <<endl;
return 1;
}

int main()
{
cout << "Hello, This is a sample test\n";
return 0;

}
Sample build file is :
all:libcfgchk_s amplelib.so

libcfgchk_sampl elib.so : $(OBJS)
$(GCC) -shared -Wl,-soname,libcfgch k_samplelib.so -o
libcfgchk_sampl elib.so $(OBJS) - -lutil -lext_stl -lprocess -lnsl -
lcfgchk_utils -ldl

I am curious to know how the .so in invoked in the program which has a
main(). Please update me on the same

Oct 19 '07 #1
1 2663
On Oct 19, 6:04 am, athr...@gmail.c om wrote:
I have created a shared library with main() .Still it is compiled and
loaded during invocation. Below is the code and build file.

sample_test.cpp
int test_method(Cfg ChkSession &s)
{
cout<<"working" <<endl;
return 1;

}

int main()
{
cout << "Hello, This is a sample test\n";
return 0;

}

Sample build file is :
all:libcfgchk_s amplelib.so

libcfgchk_sampl elib.so : $(OBJS)
$(GCC) -shared -Wl,-soname,libcfgch k_samplelib.so -o
libcfgchk_sampl elib.so $(OBJS) - -lutil -lext_stl -lprocess -lnsl -
lcfgchk_utils -ldl

I am curious to know how the .so in invoked in the program which has a
main(). Please update me on the same
I believe that in the .so main is a "weak symbol" which prevents the
multiply defined symbol error you are expecting. The global symbol
main is chosen preferentially over the weak symbol main in the shared
object.
http://www.tortall.net/projects/yasm...t-elf-dir-weak

YT,
Dan Noland
http://nolandda.org/

Oct 19 '07 #2

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

Similar topics

0
2187
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful. Php script can load my library successfully. And Now I port my library to HP(HP-UX 11.0) and IBM(AIX 4.1.3) system.
0
2264
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled with the Sun Compiler version 8. My problem is that EVERYTHING builds great EXCEPT that the 6b distribution of JPEG will NOT build a shared...
1
4411
by: AH | last post by:
I have two functions in my shared library which are declared as follows: void setName(const std::string& str); std::vector<std::string> getInfo(); Since the code is compiled and in shared library. Every thing is great if the customer of my shared library is using the same compiler version (and same STL version). I am wondering if the...
2
2025
by: santa19992000 | last post by:
Confusing th eword with "library", "shared library" and how to use these things in real C project, is there any small example I can take a look. Thanks.
5
3986
by: Ivan | last post by:
I am used to VB6 and am not sure how to do this in Vstudio .NET. I have a main form which calls other forms. I want to disable that main form while other ones are called. I tried hiding it and creating a new instance of the main form when returning to it but than my application is just creating more forms. How do I hide the main form and...
4
1530
by: Bob Day | last post by:
Using VS 2003, VB.net , MSDE .... I am confused by the help example below. In a sub main (whether in a module or winform), do you have to explicitly start the Main_Thread, as they do in this example? If the answer is not always, when and where would you and for what reasons? I don't explicitly start the thread (although I give it a name)...
3
7830
by: Shawnk | last post by:
I use two classes to manage the Main() command line (and alot of other stuff) for my prototyping environment. I tryed putting the MainClass in a DLL and just having the other class (which gets modified on a per project basis) as the 'program.cs' file (the only *.cs file). I keep getting 'Main() not defined error' even though it was...
14
1665
by: Sumit77Sen | last post by:
who calls main() ?
2
2167
by: blackbiscuit | last post by:
Dear All, Now in my current developing project, I have defined a global object in the main program . In dlls, there are also some static object whose constructor will use the global object in the main program. But the problem is always the initialization of the dll is prior to the main program. How can I do if I wanna the main program be...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.