473,396 Members | 1,987 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,396 software developers and data experts.

how to convert program to lib?

joe
Hi I have a little executable that has this description for the main
procedure
main(int argc, char **argv)
is it possible to call the program from another program if i compile it as
a lib? or do i need to modifiay the main function to a different name? do i
need to create a .h file for the procedure definition? where can i find
info about this? thanks
Jul 22 '05 #1
1 3010
joe wrote in news:Xn****************************@207.69.154.205 :
Hi I have a little executable that has this description for the main
procedure
main(int argc, char **argv)
is it possible to call the program from another program if i compile
it as a lib? or do i need to modifiay the main function to a different
name? do i need to create a .h file for the procedure definition?
Yes (to both question's).
where can i find info about this? thanks


In your compilers documentation or online help, compiler specific
newsgroups (there FAQ's if they have them). Also maybe there is
some third party library (with sources preferably) that you can
get for you compiler, if so, take a look see how they do it.
The easy part is rewriting the source code:

rename int main( int argc, char **argv ) to (say (*))

int yourlib_main( int argc, char **argv )
{
// current code.

// note if you may need to add:

return 0; // as main() is special in that you can
// omit its return statement
}
Create a header file:

#if !defined( YOURLIB_GUARD_H )
#define YOURLIB_GUARD_H

#if !defined( __cplusplus )
# error "Must use C++ with yourlib"
#endif

int yourlib_main( int argc, char **argv );

#endif

I'd also suggest while your at it you may want to change the arguments
to yourlib_main() to something easier to create maybe:

#include <vector>
#include <string>

int yourlib_main( std::vector< std::string > const &args );

(*) Replace yourlib/YOURLIB above with something more meaninfull
and unique to this library you are creating.

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #2

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

Similar topics

2
by: Steve Payne | last post by:
I have an Access97 Database on one PC and a 2nd PC that just need to be able to query the Database. Can I convert a program (that I wrote in Access97) to an .exe file for the 2nd PC? If so,...
6
by: Ken | last post by:
When running a program in the debugger, what would cause it to crash without any error messages? I get "The program has exited with code 0 (0x0)". The program is a MDI app with threading for...
2
by: jocobunshin | last post by:
Hi there! I'm new in Turbo C... uhmm our teacher gave us a project to make a program in Turbo C. Im from the Philippines, and our project is due on tuesday, februrary 13, 2007... can anyone check my...
10
by: minterman | last post by:
1. the program needs to convert btu to jules 2. Convert calories to joules 3. Convert joules to joules 4 exit the program. if the user type anything other than 1-4 the program should print a...
40
by: Tameem | last post by:
hi my name is tameem. i am a new c programmer. in a c program i want to give input ""tameem"" and the output will be ""xdphhp"" in a short: the character ""a"" will be replaced by ""d"" i can...
6
by: nickels | last post by:
Ok i already made a program that uses char and when someone enters a letter it will give them a conversion i made for that letter. That looks like this. import java.util.Scanner; public class...
13
by: Liang Chen | last post by:
Hope you all had a nice weekend. I have a question that I hope someone can help me out. I want to run a Python program that uses Tkinter for the user interface (GUI). The program allows me to type...
0
by: Andy202 | last post by:
I have a program that sends and receives data via a TCP/IP socket, but I would like to convert this application to a Shared Library so that other programs can use this library to send() and receive()...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
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: 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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...

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.