That's only because I live nearly halfway round the world, and I only caught on when I read it for the 5th time, all the while thinking something was up :P
Ben
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Im the one who posted this comment and would want to know how to add my custom function to a library viz to math.lib i think i need obj file for that or is there any other method
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well...to add a custom function to a library, you need to get the library source and add it in. If you don't have the source, then you can't edit what functions and whatnot are in the library. Furthermore, since you did mention .obj and .lib files, I gather that these are the extensions to these libraries, and if so, you cannot use them with GCC at all, as it uses the Unix .o and .a formats, not the more common Windows .obj and .lib formats.
Benjamin Lau
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-06-18
Contrary to Benjamin's coment, it is actually possible to add object files to existing libraries using the GNU ar (archive) utility, which is included with Dev-Cpp.
However it would be very unwise to add your own object code to an existing 3rd party or standard library. The library would be overwritten if you were to upgrade, and you would loose your 'customisation'.
A much better approach would be to create your own library. This is easily done in Dev-C++ via File|new|Project|Static Library. make sure you select the appropriate language (C or C++), and simply add the sourcefiles containing the functions you wish to place in the library (or 'archive'as they are usually referred to in GNU parlance).
In order to make the most efficient use of the archive, each function with an external interface should be defined in a separate source file. That way only the code that a subsequent program actually calls will get linked. If you place all the functions in one file, the whole library will get linked, and there will be no benefit of using an archive over the original object file.
You should also be aware (as you seem somewhat confused by the issue), that in GNU, the convention for object code files is to use the extension .o, not .obj. And equally library files have the extension .a not .lib. So when you say ".obj file not created", then you are looking for the wrong thing, because a .o file will have been created.
Note that .o and .a are simply file name conventions and not indicuitive of any particular "format". The GNU toolchain can actually support multiple object file formats. Equally .obj is not a format - both Borland and Microsoft for example use the .obj extension, but thier object code is not compatible.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Oopsie, forgot about the whole same/different extension != same/different format issue, and that he could just link an object file back to the archive library :$
But in any case, I'm just curious, but why do you want to add your own custom function to the API library? Does it override an existing function? If yes, then no, you cannot do such a thing, GCC will complain of multiple definitions of the same function.
Benjamin Lau
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Whenever i compile a C file i dont get the obj file being created. whats the problem
If your code is compiling and linking normally into an executable, then the object file is deleted.
If it is not generating an executable successfully, then you need to post your "basic 3'.
Wayne
Just in case, but they're .o files, not .obj. Both are very different formats, and I don't think there exists any way to convert between the two,
Darn, that'll teach me to answer early in the morning...
Thanks for the save Benjamin!
Wayne
That's only because I live nearly halfway round the world, and I only caught on when I read it for the 5th time, all the while thinking something was up :P
Ben
Im the one who posted this comment and would want to know how to add my custom function to a library viz to math.lib i think i need obj file for that or is there any other method
Well...to add a custom function to a library, you need to get the library source and add it in. If you don't have the source, then you can't edit what functions and whatnot are in the library. Furthermore, since you did mention .obj and .lib files, I gather that these are the extensions to these libraries, and if so, you cannot use them with GCC at all, as it uses the Unix .o and .a formats, not the more common Windows .obj and .lib formats.
Benjamin Lau
Contrary to Benjamin's coment, it is actually possible to add object files to existing libraries using the GNU ar (archive) utility, which is included with Dev-Cpp.
However it would be very unwise to add your own object code to an existing 3rd party or standard library. The library would be overwritten if you were to upgrade, and you would loose your 'customisation'.
A much better approach would be to create your own library. This is easily done in Dev-C++ via File|new|Project|Static Library. make sure you select the appropriate language (C or C++), and simply add the sourcefiles containing the functions you wish to place in the library (or 'archive'as they are usually referred to in GNU parlance).
In order to make the most efficient use of the archive, each function with an external interface should be defined in a separate source file. That way only the code that a subsequent program actually calls will get linked. If you place all the functions in one file, the whole library will get linked, and there will be no benefit of using an archive over the original object file.
You should also be aware (as you seem somewhat confused by the issue), that in GNU, the convention for object code files is to use the extension .o, not .obj. And equally library files have the extension .a not .lib. So when you say ".obj file not created", then you are looking for the wrong thing, because a .o file will have been created.
Note that .o and .a are simply file name conventions and not indicuitive of any particular "format". The GNU toolchain can actually support multiple object file formats. Equally .obj is not a format - both Borland and Microsoft for example use the .obj extension, but thier object code is not compatible.
Clifford
Oopsie, forgot about the whole same/different extension != same/different format issue, and that he could just link an object file back to the archive library :$
But in any case, I'm just curious, but why do you want to add your own custom function to the API library? Does it override an existing function? If yes, then no, you cannot do such a thing, GCC will complain of multiple definitions of the same function.
Benjamin Lau