|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#8
|
|||
|
|||
|
Re: How Does Compiling Work?
Quote:
If the library is static, it's code will be stuck in with the rest of the application's which is using it, and the .lib file will probably contain the object file code (an intermediate form of code before machine code, with stuff such as relocation information) of the library. If the library is shared, the .lib file will probably contain a list of functions which exist in the shared library. The actual code will be separated from the application's which uses it- in a PE file on Windows (.exe, .dll) or .out in vxWorks. This makes it possible to update the library an application is using without recompiling the application, also promoting modularity and code reuse. The purpose of the .lib file for applications on conventional operating systems here is usually to facilitate the process of "static" linking. However, a lot of this information is irrelevant to the poster's question. For programming with the vxWorks operating system on the cRIO, it is important to understand in the compile process the distinction between "static" and "dynamic" linking. On vxWorks, .out files (your program) are linked dynamically. What does this mean? Lets say you have a C/C++ program with a function declared in a header file, and your code calls it, but you haven't compiled the definition of the function (it is unwritten in your project). On a conventional operating system such as Windows or Unix the compiler will resolve links between functions and function calls at compile time- meaning that the application's exe will know for sure where those functions are once it is constructed. In other words, if you are using a function which is declared to exist but not defined you will get an error at compile time. This is static linking. On vxWorks, you will not get an error at compile time. You will get an error at runtime, because when vxWorks loads programs it dynamically links all applications calls to functions at runtime (resolves where functions are at the load time, instead of compile time). This is dynamic linking. Discovering linker errors at runtime can lead to some hard-to-resolve crashes if you aren't debugging an application when it's run by the vxWorks program loader. So, you should usually always run your program via debug kernel task. The WPI library is not part of the cRIO image. It is a static library, merged in with the rest of your code at compile time. That's why it is so easy to recompile and use your own version of WPI lib. For a complete view of the traditional compilation process, I would recommend reading Compilers: Principles, Techniques, and Tools (the dragon book). Last edited by EdenA : 08-03-2011 at 00:01. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|