Welcome, Guest. Please login or register.

Author Topic: put library in code  (Read 2253 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline kas1eTopic starter

put library in code
« on: March 01, 2005, 03:59:09 AM »
hello 2 all, one more lame question. for example i have lala.library (68k/hunk) and this kind of code:

// ----
OpenLibrary(lala.library)
using library calls
CloseLibrary(lala.library)
// ----

Well, in this code i must use inxternal lala.library. Can i create internal code from lala.library ? I mean, i do not want open external library, i just to want put all data to one executable (put library in code). Any way ? I need it for sasc/vbcc and in last case for gcc maybe. I do not have sources of this library. So, maybe any 3d party tools ? fd2pragma maybe ? Of course i can create char array from my library, after run code create file from this char, open it as library, use calls, close, erase :) but it is a mess..

sorry for poor english.
 

Offline FluffyMcDeath

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 3440
    • Show only replies by FluffyMcDeath
Re: put library in code
« Reply #1 on: March 01, 2005, 06:25:30 AM »
Not only is there no easy way to do this without source code, it is likely that there is no LEGAL way to do this.

If you do not have the source code I assume that the library you refer to does not belong to you. Building it into your own code is likely to be a breach of some intellectual property law.

Also, I can't really think of a good reason to do this (except for as a means of distributing libraries that you depend on that you are not entitled to distribute).
 

Offline kas1eTopic starter

Re: put library in code
« Reply #2 on: March 01, 2005, 07:10:04 AM »
these librarys as 'freeware', but too many authorsdead/leave/etc. So, it is no way to have source code (but of course these library is free).

Anyway, here is no question about LAW/RIGHT, here is technical question.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: put library in code
« Reply #3 on: March 01, 2005, 07:54:02 AM »
@kas1e
Quote
these librarys as 'freeware', but too many authorsdead/leave/etc.

This fights against the very idea of libraries: Making it easy to upgrade the library!

Quote
Anyway, here is no question about LAW/RIGHT, here is technical question.

Embedding a library into some binary is possible, and it has been done. But since it's ugly and totally against the idea of the shared libraries, I won't get into details.

Just provide a proper install script that copies the library over (unless if there's newer version installed already).
 

Offline kas1eTopic starter

Re: put library in code
« Reply #4 on: March 01, 2005, 08:41:16 AM »
well. here is example, we have:
1.little binary(20k)
2.little library(10k)
3.tool like UPX (which pack executable with adding self decrunch data + decrunch header into new exefile)

We pack exe, to 10k. And can't pack library. If, we embedding library to binary, it possible to pack all code. And it will look more compactly.

Next example, it is too many buggest amiga librarys from version to version. For example user have 1.2 version of library (it is work fine with some user programs) and i have 1.3 (it is work for me too, but for some programs from user, it is do not work, becouse problem in new library fixes/codes/etc). I am replace user library, and .. it is suxx. So, it is one more + to embedet library to binary.


ps. of course i am understand that it's not good way. but! i do not have to create big project with this kind of hack, i just want to create some little project.
 
 

Offline Cymric

  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 1031
    • Show only replies by Cymric
Re: put library in code
« Reply #5 on: March 01, 2005, 09:51:47 AM »
You really do not need to pack executables anymore. Packing is ugly, unnecessary, and fscks up the DOS loader. I'll admit, everything in one file looks cool. But there really is little difference between creating a directory and dumping all stuff there and a single file. Second, if library versions are so important, you embed a check in your code with the OpenLibrary() call to print a warning that if the right version is not present, the program will not run correctly. You ship the program with the correct version of the library. If the code is so sensitive to the correct version, you might want to think about coding a workaround, bugging the author, or if he is not active any longer, creating your own library to do the job. Finally, embedding code into your own executable requires you to know a lot about the library's own code and data segments and making sure those sections end up in the right kind of memory. Under OS3- that doesn't make one iota of difference, but OS4+ might actually respect certain flags and allocate memory appropriately. In other words, you need to mimick the OpenLibrary()-process on your own: bad, bad idea.

It is sooo much easier just to ship the right version with your code and issue a warning otherwise, it's almost painful.
Some people say that cats are sneaky, evil and cruel. True, and they have many other fine qualities as well.
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: put library in code
« Reply #6 on: March 01, 2005, 12:32:38 PM »
Privet! :)

Are u trying to make a cli command?

Or will ur util be loaded from workbench with an icon?

Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline Trev

  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1550
  • Country: 00
    • Show only replies by Trev
Re: put library in code
« Reply #7 on: March 07, 2005, 11:52:29 PM »
If you have the function descriptor, then you know how to call the library's functions. If you have the library, then you know how to determine the offsets of the library's functions. It might be possible to link the object code into yours and call the functions with an understanding of the overall layout; however, if the library calls any of its own functions or any other internal functions, you're still hosed. So, you'd have to decompile the library and go from there.

So, anything is technically possible, but is the benefit worth the cost?

Trev

P.S. In the United States, all creative works, including software source and object code, are implicitly copyrighted unless they're explicitly placed in the public domain. "Freeware" is copyrighted software licensed free of charge for limited use. Be sure to consult your own country's copyright laws, international treaties, and the country of origin's copyright laws before publicly distributing your work. (Private, non-commerical use typically qualifies as a fair use in countries that apply the fair use doctrine.)