473,327 Members | 2,007 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,327 software developers and data experts.

Learner changing executable to library

My little app to scan World of Warcraft auction scans now works in that
it generates useful tables in CSV format that the user can do wahtever
they like with.

I created it as a console application. If I want to put a File
Selection GUI on it, the nicest way would be to change it to a library
rather than start again. I think in Windows this means a dll.

Is this possible? Its only 400 lines of code, a lot of which has
"Learner" stamped all over it but learning to make a library is my next
step.

If there is a URL to how this works and what UI hsould read, please let
me know.

Thanks.

Oct 2 '06 #1
17 1659
If there is a URL to how this works and that* I* should* read, please
let me know. Sorry - awful spelling - its Monday and late night last
night ;-)

Oct 2 '06 #2
pkirk25 said:
My little app to scan World of Warcraft auction scans now works in that
it generates useful tables in CSV format that the user can do wahtever
they like with.

I created it as a console application. If I want to put a File
Selection GUI on it, the nicest way would be to change it to a library
rather than start again. I think in Windows this means a dll.
Can be, but needn't be. You can do static libraries in Windows.

And if you do go the DLL route, it is possible to do so *without* hacking
your source code full of Microsoft-specific junk. (Anyone who tells you
different doesn't know what they're talking about.)
Is this possible? Its only 400 lines of code, a lot of which has
"Learner" stamped all over it but learning to make a library is my next
step.
I have a page which explores this subject (albeit rather briefly) on my Web
site:

http://www.cpax.org.uk/prg/portable/c/statlibs.php

It is, at least, a place to start.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 2 '06 #3
Can be, but needn't be. You can do static libraries in Windows.

And if you do go the DLL route, it is possible to do so *without* hacking
your source code full of Microsoft-specific junk. (Anyone who tells you
If the app is useful it will need to run on Mac as well as Windows.

If I read correctly, I rename main() to do_something() and make sure
the headers are in the library path and I'll be able to call
do_something() from the GUI app.

I will read up on how to do this from within the VC++ IDE.

Thanks fo ra very useful web page.

Oct 2 '06 #4
Can be, but needn't be. You can do static libraries in Windows.
>
And if you do go the DLL route, it is possible to do so *without* hacking
your source code full of Microsoft-specific junk. (Anyone who tells you
If the app is useful it will need to run on Mac as well as Windows.

If I read correctly, I rename main() to do_something() and make sure
the headers are in the library path and I'll be able to call
do_something() from the GUI app.

I will read up on how to do this from within the VC++ IDE.

Thanks for a very useful web page.

Oct 2 '06 #5
pkirk25 wrote:
My little app to scan World of Warcraft auction scans now works in that
it generates useful tables in CSV format that the user can do wahtever
they like with.

I created it as a console application. If I want to put a File
Selection GUI on it, the nicest way would be to change it to a library
rather than start again. I think in Windows this means a dll.

Is this possible? Its only 400 lines of code, a lot of which has
"Learner" stamped all over it but learning to make a library is my next
step.

If there is a URL to how this works and what UI hsould read, please let
me know.
The comp.lang.c part of your answer:
Make your source code structurally library-ready, i.e. plan which
interface you want to use: Does it come down to one function called
from main()? Do you want to pass in FILE pointers or FILE names?
.... Split your source files accordingly and provide headers containing
this interface.
Now, make a library (however this may work) from everything but the
file containing main().

<OT>
I just entered
how to create a dll with visual studio
in google and the first link did not seem too bad.
The DLL mechanism offers a kind of special linkage (C has only
extern, internal or no linkage), which lead to __declspec()
in function declarations.
You only have to adjust the "interface headers" accordingly.
If you want your source to be portable, I suggest using macros
to get rid of the need for three variants of the interface headers:
#ifdef WhateverYouNeedToFindOutItsWindowsIReallyDontKnowI tForSure
# ifdef MY_INTERFACE_EXPORT
# define PROVIDE_SPECIAL_LINKAGE __declspec(dllexport)
# else
# define PROVIDE_SPECIAL_LINKAGE __declspec(dllimport)
# endif
#else
# define PROVIDE_SPECIAL_LINKAGE
#endif
Then, you only need to #define MY_INTERFACE_EXPORT when building
the DLL and can reuse the interface headers.
Now, you just have to insert PROVIDE_SPECIAL_LINKAGE wherever needed.
</OT>
Note that I am not an expert in this area, so my advice may be
incorrect, incomplete, or not the best possible. This is better
asked in a newsgroup where developing under Windows is on-topic.
Do not forget to check for their FAQ.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Oct 2 '06 #6
Michael Mair said:

<snip>
I just entered
how to create a dll with visual studio
in google and the first link did not seem too bad.
The DLL mechanism offers a kind of special linkage (C has only
extern, internal or no linkage), which lead to __declspec()
in function declarations.
You don't need any of that junk. You can sidestep it all by writing a little
..DEF file. Far cleaner, and doesn't pollute the C source.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 2 '06 #7
Richard Heathfield wrote:
You don't need any of that junk. You can sidestep it all by writing a little
.DEF file. Far cleaner, and doesn't pollute the C source.
Pretty sure this is a common method the Cygwin guys utilize as well.
Win32 is such a POS.
Oct 2 '06 #8
Richard Heathfield wrote:
Michael Mair said:
<snip>
>>I just entered
how to create a dll with visual studio
in google and the first link did not seem too bad.
The DLL mechanism offers a kind of special linkage (C has only
extern, internal or no linkage), which lead to __declspec()
in function declarations.

You don't need any of that junk. You can sidestep it all by writing a little
.DEF file. Far cleaner, and doesn't pollute the C source.
Which once more leads to the conclusion: Ask where its on-topic :-)

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Oct 2 '06 #9
Michael Mair said:
Richard Heathfield wrote:
>Michael Mair said:
<snip>
>>>I just entered
how to create a dll with visual studio
in google and the first link did not seem too bad.
The DLL mechanism offers a kind of special linkage (C has only
extern, internal or no linkage), which lead to __declspec()
in function declarations.

You don't need any of that junk. You can sidestep it all by writing a
little .DEF file. Far cleaner, and doesn't pollute the C source.

Which once more leads to the conclusion: Ask where its on-topic :-)
Actually, if he had done so, he'd probably have got the declspec answer, and
bye-bye portability.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 2 '06 #10
Richard Heathfield wrote:
Michael Mair said:
>>Richard Heathfield wrote:
>>>Michael Mair said:
<snip>

I just entered
how to create a dll with visual studio
in google and the first link did not seem too bad.
The DLL mechanism offers a kind of special linkage (C has only
extern, internal or no linkage), which lead to __declspec()
in function declarations.

You don't need any of that junk. You can sidestep it all by writing a
little .DEF file. Far cleaner, and doesn't pollute the C source.

Which once more leads to the conclusion: Ask where its on-topic :-)

Actually, if he had done so, he'd probably have got the declspec answer, and
bye-bye portability.
So, you say "ask in clc as you may get better answers even if your
request is OT"...

GD&R
Michael

P.S.: Well, I have never heard of .DEF files before, either.
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Oct 2 '06 #11
Michael Mair said:
Richard Heathfield wrote:
>Michael Mair said:
>>>Richard Heathfield wrote:
Michael Mair said:
<snip>

>I just entered
how to create a dll with visual studio
>in google and the first link did not seem too bad.
>The DLL mechanism offers a kind of special linkage (C has only
>extern, internal or no linkage), which lead to __declspec()
>in function declarations.

You don't need any of that junk. You can sidestep it all by writing a
little .DEF file. Far cleaner, and doesn't pollute the C source.

Which once more leads to the conclusion: Ask where its on-topic :-)

Actually, if he had done so, he'd probably have got the declspec answer,
and bye-bye portability.

So, you say "ask in clc as you may get better answers even if your
request is OT"...
Er... er... er... y... No! No, what I'm saying is that you should have asked
in clc if and only if you end up getting a better answer there than you
would have got anywhere else. :-)

(This has the advantage that the clc cabal[1] can decide retrospectively
whether to consider an article topical.)

P.S.: Well, I have never heard of .DEF files before, either.
You'll never be able to say that again...
[1] TINC.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 2 '06 #12
I have made the executable into a static lib jsut by changing the term
int main() to int read_source_lua and adding a header. Executable was
11kb. Even when VC optimizes for smallest size, the library is now
76kb.

So I go back to scratch and make sure that there are no pre-compiled
headers and stuff checked in by VC. Make new project with same source
files and it is same size.

Is this normal?

Oct 2 '06 #13
pkirk25 said:
I have made the executable into a static lib jsut by changing the term
int main() to int read_source_lua and adding a header. Executable was
11kb. Even when VC optimizes for smallest size, the library is now
76kb.
So what? What matters is not the size of the library, but the size of what
is taken out from the library. Think of your local lending library. It's
rather larger - in fact, very very very much larger - than the total size
of all the books it stores. Do you care, when you are walking home with the
latest Tom Clancy burning a hole in your carrier bag? Of course not. You
don't have to cart the library home with you, after all.
So I go back to scratch and make sure that there are no pre-compiled
headers and stuff checked in by VC. Make new project with same source
files and it is same size.

Is this normal?
Yes, it's housekeeping information and stuff like that. Don't worry about
it.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 2 '06 #14
nt

Oct 2 '06 #15
On 2 Oct 2006 00:27:44 -0700, in comp.lang.c , "pkirk25"
<pa*****@kirks.netwrote:
>
I created it as a console application. If I want to put a File
Selection GUI on it, the nicest way would be to change it to a library
rather than start again. I think in Windows this means a dll.
Nah, just create a GUI app with your favorite C GUI app builder
environment, and include the source files in it.
>Is this possible?
Undoubtedly, but you need to ask in a Windows or Linux or whatever
group to get details.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 2 '06 #16
On Mon, 02 Oct 2006 08:16:15 +0000, in comp.lang.c , Richard
Heathfield <in*****@invalid.invalidwrote:
>Michael Mair said:

<snip>
>I just entered
how to create a dll with visual studio
in google and the first link did not seem too bad.
The DLL mechanism offers a kind of special linkage (C has only
extern, internal or no linkage), which lead to __declspec()
in function declarations.

You don't need any of that junk. You can sidestep it all by writing a little
.DEF file. Far cleaner, and doesn't pollute the C source.
You don't need that /either/ but further discussion is offtopic here
of course.

--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Oct 2 '06 #17
Mark McIntyre said:
On Mon, 02 Oct 2006 08:16:15 +0000, in comp.lang.c , Richard
Heathfield <in*****@invalid.invalidwrote:
>>
You don't need any of that junk. You can sidestep it all by writing a
little .DEF file. Far cleaner, and doesn't pollute the C source.

You don't need that /either/ but further discussion is offtopic here
of course.
And that's a shame, because you just managed to intrigue me.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Oct 2 '06 #18

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

Similar topics

1
by: sarmin kho | last post by:
Hi Pythoners, i remember that i saw posting about changing the icon of a python executable but i kind of lost where to find the posting... basically, this is my first time using the py2exe to...
17
by: Filipe Martins | last post by:
Hello. I've read somewhere that the executable is smaller if we use a source file for each function! So, I tested this with gcc and it seams to confirm! What seams to happen is that if we call...
0
by: Simon | last post by:
I've had enough of C# Learner. I've had enough of his complaining about using parentheses for every 'if' statement. I've had enough of his complaining about having to mix assignment of return...
1
by: Itomeshi | last post by:
I'm currently writing a simple, unmanaged, VC++ 2003 unmanaged app without .NET libraries (for project specific reasons). My current stumbling block is how to delete a service. The only method I...
8
by: suresh_C# | last post by:
Dear All, What is difference between Portable Executable (PE) file and a Assembly? Thanks, Mahesh
16
by: John | last post by:
Does the length of my C variable names have any affect, performance-wise, on my final executable program? I mean, once compiled, etc., is there any difference between these two: number = 3; n =...
1
by: sunil | last post by:
Hi, I want to change the default installation folder to my own path. I did it by changing the application folder's DefaultLocation property. The installation works fine as long the path that I...
6
by: vedrandekovic | last post by:
Hello, I am trying to make a program for 3D modelling with "programming".And I want make my own program commands, for example when user type code in my program: "<<koristiti>OS"- (THIS IS...
16
by: Erwin Moller | last post by:
Why is a binary file executable? Is any binary file executable? Is only binary file executable? Are all executable files binary? What is the connection between the attribute of binary and that of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.