Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-06

DLL Linking

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Pianoman

Hi everyone, I have one question: Is it possible to link a Routine from DLL to my exe directly. Point is that I don't want distribute other files with the program and it would be nice to have only one executable nothing more.
I use Bass audio library for playback and I am interested if is it possible to link it together with my application.
Thanx
Pianoman

Earlier message 332 lines
----- Original Message ----- From: To: Sent: Tuesday, June 21, 2005 12:00 PM Subject: fpc-pascal Digest, Vol 10, Issue 15 > Send fpc-pascal mailing list submissions to > > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > or, via email, send a message with subject or body 'help' to > > > You can reach the person managing the list at > > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of fpc-pascal digest..." > > > Today's Topics: > > 1. Re: selecting target processor (Jonas Maebe) > 2. Re: selecting target processor (Eduardo) > 3. strange behaviour of readkey...or not (Darius Blaszijk) > 4. Re: strange behaviour of readkey...or not (Florian Klaempfl) > 5. Re: strange behaviour of readkey...or not (Darius Blaszijk) > 6. Freepascal Advocate Store (L505) > 7. Small project $ (Paul Aviles) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 20 Jun 2005 15:36:10 +0200 > From: Jonas Maebe > Subject: Re: [fpc-pascal] selecting target processor > To: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed > > > On 20 jun 2005, at 09:59, Marc Santhoff wrote: > > > So it should work: > > > > I'm using "-dRELEASE" for releasing and my fpg.cfg has standard "- > > OG2p3" > > and "-Xs". Testing is done with "-XX -B". > > Yes, it should. > > >> Can you figure out which instruction it is that causes this? > > > > How would I do that? Would a saved core dump do? It seems to occur on > > when redirecting stdout to a file, but I'm not sure yet. > > Normally, you'd do this by running the program under gdb and checking > what the faulting instruction is. A coredump should contain the > necessary information as well, yes. > > > Jonas > > > > > ------------------------------ > > Message: 2 > Date: Mon, 20 Jun 2005 17:19:51 +0200 > From: Eduardo > Subject: Re: [fpc-pascal] selecting target processor > To: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; charset="us-ascii"; format=flowed > > At 15:36 20/06/2005, you wrote: > > >On 20 jun 2005, at 09:59, Marc Santhoff wrote: > > > >>So it should work: > >> > >>I'm using "-dRELEASE" for releasing and my fpg.cfg has standard "- OG2p3" > >>and "-Xs". Testing is done with "-XX -B". > > > >Yes, it should. > > > >>>Can you figure out which instruction it is that causes this? > >> > >>How would I do that? Would a saved core dump do? It seems to occur on > >>when redirecting stdout to a file, but I'm not sure yet. > > > >Normally, you'd do this by running the program under gdb and checking > >what the faulting instruction is. A coredump should contain the > >necessary information as well, yes. > > Are you using any dll or lib.so :? Perhaps the external code is compiled > for a specific processor. > > > **************************************************************************** ********************************************************************** > This document represent my ideas. They are original from me. It's forbidden > think the same than me, without previous payment. > If you agree me, PAY. > > > > > ------------------------------ > > Message: 3 > Date: Mon, 20 Jun 2005 19:34:10 +0200 > From: "Darius Blaszijk" > Subject: [fpc-pascal] strange behaviour of readkey...or not > To: > Message-ID: > Content-Type: text/plain; charset="iso-8859-1" > > Hi there, > > I have a console app that reads keys being pressed and then does some > action. In short it would be like this: > > repeat > if fileage(myfile) imyfile then > begin > writeln('file changed'); > imyfile := fileage(myfile); > end; > > ch := readkey; > until ch = 'q' > > So what I want is that the fileage test is done continously and when a user > presses a key some other procedure is executed. But the problem is that when > "ch := readkey" is reached, the app seems to stay waiting until a key is > pressed. In other words it only does the fileage test when I press a key > other than q. In my example the fileage test is only done once. > > Am I under the wrong impression that I should pull it off using readkey?? > What is the alternative?? > > Darius Blaszijk > > > > > ------------------------------ > > Message: 4 > Date: Mon, 20 Jun 2005 19:37:37 +0200 > From: Florian Klaempfl > Subject: Re: [fpc-pascal] strange behaviour of readkey...or not > To: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; charset=us-ascii > > Darius Blaszijk wrote: > > > Hi there, > > > > I have a console app that reads keys being pressed and then does some > > action. In short it would be like this: > > > > repeat > > if fileage(myfile) imyfile then > > begin > > writeln('file changed'); > > imyfile := fileage(myfile); > > end; > > > > ch := readkey; > > until ch = 'q' > > > > So what I want is that the fileage test is done continously and when a user > > presses a key some other procedure is executed. But the problem is that when > > "ch := readkey" is reached, the app seems to stay waiting until a key is > > pressed. In other words it only does the fileage test when I press a key > > other than q. In my example the fileage test is only done once. > > > > Am I under the wrong impression that I should pull it off using readkey?? > > What is the alternative?? > > Do check of keypressed first: > http://www.freepascal.org/docs-html/rtl/crt/keypressed.html > > > > ------------------------------ > > Message: 5 > Date: Mon, 20 Jun 2005 19:48:45 +0200 > From: "Darius Blaszijk" > Subject: Re: [fpc-pascal] strange behaviour of readkey...or not > To: "FPC-Pascal users discussions" > Message-ID: > Content-Type: text/plain; charset="iso-8859-1" > > Florian, > > Thanks. I have fixed it using: > > if KeyPressed then > ch := ReadKey > else > ch := ''; > > I know I should have know better, but for some strange reason only readkey > in a previous version seemed to work just fine. Thats why I was confused. > > Darius Blaszijk > > ----- Original Message ----- > From: "Florian Klaempfl" > To: "FPC-Pascal users discussions" > Sent: Monday, June 20, 2005 7:37 PM > Subject: Re: [fpc-pascal] strange behaviour of readkey...or not > > > > Darius Blaszijk wrote: > > > > > Hi there, > > > > > > I have a console app that reads keys being pressed and then does some > > > action. In short it would be like this: > > > > > > repeat > > > if fileage(myfile) imyfile then > > > begin > > > writeln('file changed'); > > > imyfile := fileage(myfile); > > > end; > > > > > > ch := readkey; > > > until ch = 'q' > > > > > > So what I want is that the fileage test is done continously and when a > user > > > presses a key some other procedure is executed. But the problem is that > when > > > "ch := readkey" is reached, the app seems to stay waiting until a key is > > > pressed. In other words it only does the fileage test when I press a key > > > other than q. In my example the fileage test is only done once. > > > > > > Am I under the wrong impression that I should pull it off using > readkey?? > > > What is the alternative?? > > > > Do check of keypressed first: > > http://www.freepascal.org/docs-html/rtl/crt/keypressed.html > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > > > ------------------------------ > > Message: 6 > Date: Mon, 20 Jun 2005 12:38:35 -0700 > From: L505 > Subject: [fpc-pascal] Freepascal Advocate Store > To: FPC-Pascal users discussions > Message-ID: > Content-Type: text/plain; charset=iso-8859-1 > > Are there any I Love Freepascal t-shirts, hats, coffee mugs, etc.? > > Love, > Lars > > > > ------------------------------ > > Message: 7 > Date: Mon, 20 Jun 2005 22:56:30 -0400 > From: "Paul Aviles" > Subject: [fpc-pascal] Small project $ > To: > Message-ID: > Content-Type: text/plain; format=flowed; charset="iso-8859-1"; > reply-type=original > > Basically a way to enable a web version of tail -f for log files. There is a > java version but we don't want the dependencies associated with java there. > Please contact me directly if anyone is interested on doing this. > > Regards, > > Paul > > > > > > ------------------------------ > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > End of fpc-pascal Digest, Vol 10, Issue 15 > ****************************************** > > > __________ Informacia od NOD32 1.1146 (20050620) __________ > > Tato sprava bola preverena antivirusovym systemom NOD32. > http://www.eset.sk > >

Reply by email

Jonas Maebe
to Pianoman
Pianoman wrote 8 lines
Hi everyone, I have one question: Is it possible to link a Routine from DLL to my exe directly. Point is that I don't want distribute other files with the program and it would be nice to have only one executable nothing more. I use Bass audio library for playback and I am interested if is it possible to link it together with my application.

I do not think it is possibly to link statically to dynamic libraries.

Jonas

Reply by email

Steve Williams
to Pianoman: Hi everyone, I have one question: Is it possible to link a Routine from DLL to my exe…
Pianoman wrote 6 lines
Hi everyone, I have one question: Is it possible to link a Routine from DLL to my exe directly. Point is that I don't want distribute other files with the program and it would be nice to have only one executable nothing more. I use Bass audio library for playback and I am interested if is it possible to link it together with my application.

The only option here is to add the DLL file as a resource to your executable. At application start, extract the resource and write out to a temporary file in the application directory. Load the DLL via LoadLibrary, get the function address via GetProcAddress. At application end, unload the library and delete the temporary file.

Note that this is not allowed on Windows XP if your application is in the Program Files directory. Applications are not allowed or should not write to their application directory due to security restrictions.

Sly This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.

Reply by email

Jeff Wormsley
to L505: | Note that this is not allowed on Windows XP if your application is in | the Program…
L505 wrote 14 lines
| Note that this is not allowed on Windows XP if your application is in | the Program Files directory. Applications are not allowed or should not | write to their application directory due to security restrictions. | | -- | Sly Really? So MS encourages you to write everything to the main drive:\temp directory (a black hole) and not your own temp directories? This reminds me of the registry. Black hole mania. So permissions in winxp are set like this as default?? :-(

At least in Pro, and most corporate environments. User settings usually go in a subdirectory like:

C:\Documents and Settings\<user name>\Application Data\<software company name>\<application name>

Or sometimes, if the installer is set up for it:

C:\Documents and Settings\All Users\Application Data\<software company name>\<application name>

Note the "All Users" folder tends to be hidden. Also, these paths can be changed in the registry, so you usually have to use the ShellAPI to get them. Permissions on the former are supposed to always allow read and writes, according to the Windows guidelines, but you'll find sometimes an admin will lock them read only.

Jeff.

P.S. I've never used this in FPC, but run into it all the time in Delphi, especially in the more locked down corporate offices, the type where you have to have an IT guy scheduled a month in advance to get anything installed and then you have to tell them up front every single folder and registry key you'll need to read and write to.

Reply by email

L505
to Steve Williams: The only option here is to add the DLL file as a resource to your executable. At…

| Note that this is not allowed on Windows XP if your application is in | the Program Files directory. Applications are not allowed or should not | write to their application directory due to security restrictions. |
| --
| Sly

Really? So MS encourages you to write everything to the main drive:\temp directory (a black hole) and not your own temp directories? This reminds me of the registry. Black hole mania.

So permissions in winxp are set like this as default?? :-(

Reply by email

Steve Williams
to L505
L505 wrote 12 lines
| Note that this is not allowed on Windows XP if your application is in | the Program Files directory. Applications are not allowed or should not | write to their application directory due to security restrictions. | | -- | Sly Really? So MS encourages you to write everything to the main drive:\temp directory (a black hole) and not your own temp directories? This reminds me of the registry. Black hole mania. So permissions in winxp are set like this as default?? :-(

By default, every user has their own temp directory (C:\Documents and Settings\username\Local Settings\Temp). This is what GetTempPath() will return by default, unless that user sets their TEMP environment variable to something else.

On Linux, the equivalent of "C:\Documents and
Settings\username\Application Data" would be a .appname folder in the user's home directory.

Code by the rules and you will find that you have fewer problems and more people will use your applications.

Sly This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.

Reply by email

L505
to Jeff Wormsley: At least in Pro, and most corporate environments. User settings usually go in a…

| C:\Documents and Settings\<user name>\Application Data\<software company | name>\<application name>
|
| Or sometimes, if the installer is set up for it: |
| C:\Documents and Settings\All Users\Application Data\<software company | name>\<application name>

Yuck, and since there is no "documents and settings" directory on Linux, it's not a cross platform way of building apps. Of course, you've always got the Linux Registry at hand, which is completely compatible with the windows one :-( Yeah, sure.

I'd rather write to the main program directory, because on all platforms, you have that directory avail. I've never been a fan of the registry either.. I think it's mainly abused for hiding program keys/shareware and trialware blockages. It's such a black hole, that people actually use it to their advantage.. to hide things, yes.

|
| P.S. I've never used this in FPC, but run into it all the time in | Delphi, especially in the more locked down corporate offices, the type | where you have to have an IT guy scheduled a month in advance to get | anything installed and then you have to tell them up front every single | folder and registry key you'll need to read and write to.

I feel your pain.. I guess I'm just living in dream world running Win 2000. I do see the "documents and settings" folder used a lot more often even in Win 2000.

I think I may continue to design software applications to write to the local program directory, even if it requires some corporate pricks 30 days to set permissions just to get the software running. I just can't design software the wrong way.

p.s. hope this isn't too off topic for the original poster, sorry to ruin the fun of your original question.

Reply by email

Michalis Kamburelis
to L505
L505 wrote 34 lines
| C:\Documents and Settings\<user name>\Application Data\<software company | name>\<application name> | | Or sometimes, if the installer is set up for it: | | C:\Documents and Settings\All Users\Application Data\<software company | name>\<application name> Yuck, and since there is no "documents and settings" directory on Linux, it's not a cross platform way of building apps. Of course, you've always got the Linux Registry at hand, which is completely compatible with the windows one :-( Yeah, sure. I'd rather write to the main program directory, because on all platforms, you have that directory avail. I've never been a fan of the registry either.. I think it's mainly abused for hiding program keys/shareware and trialware blockages. It's such a black hole, that people actually use it to their advantage.. to hide things, yes. | | P.S. I've never used this in FPC, but run into it all the time in | Delphi, especially in the more locked down corporate offices, the type | where you have to have an IT guy scheduled a month in advance to get | anything installed and then you have to tell them up front every single | folder and registry key you'll need to read and write to. I feel your pain.. I guess I'm just living in dream world running Win 2000. I do see the "documents and settings" folder used a lot more often even in Win 2000. I think I may continue to design software applications to write to the local program directory, even if it requires some corporate pricks 30 days to set permissions just to get the software running. I just can't design software the wrong way.

Uh, don't write data to the program directory. This is not only an issue for Windows XP, this is an issue for all operating systems with multi-user environments, including Unices. Your program should never modify any files inside it's directory, otherwise you're running into many problems (security-related but also share-related, when multiple users use and run your program). Not to mention that the "usual" program on UNIX does not have anything like "my directory". Program data is scattered over /bin (or /usr/bin), /etc/, /usr/share/<program-name> etc. And you shouldn't write anything in these directories (well, unless you really have a good reason for storing some system-wide things, that really should be set for all users, like highscores data for games or hardware configuration data; but then you have to carefully resolve those security-related and share-related problems yourself).

The proper place to store user-specific settings under Windowses is to use the mentioned

C:\Documents and Settings\<user name>\Application Data\<application name>

For UNIXes, this is

/home/<user name>/.<application name>

But actually, you should never hardcode such paths inside your program. They may be modified by many various things by system administrator, both under Windowses and Unices. And your program should adjust to it. So the fact that directory like "Documents and Settings" does not exist under Linux is not a portability problem... Because even if your program is Win32-specific, you shouldn't hardcode anywhere the string 'Documents and Settings'.

Look at GetAppConfigDir and related routines from sysutils to correctly (and portably) get directory where you should write configuration data of your program
([http://www.freepascal.org/docs-html/rtl/sysutils/getappconfigdir.html]).

Michalis

Reply by email