Frequently Asked Questions (FAQs)

1) I get an "undefined reference to "_foo@12". What do I do ?

This means that the linker is missing the definitions of a library or that you have forgotten to add a source file in the list of sources. You should add the library where the definition of foo is (ignore the leading underscore, and anything after the '@').

2) How do I add a library to the project?

Go to the main menu in the 'options' menu bar. There choose 'Configuration'. The Configuration tab opens. In this tab, choose the 'Linker' tab. There you will find an entry field with 'Additional Libraries'. Write in the name of your library. For lcc libraries, you do not need to indicate the path. For other libraries you should indicate it.

3) I still get an undefined to _xxx even if I do include the library.

This can happen when you use a _stdcall function, but forget to include the corresponding header file. For instance, if you call CreateWindow without include <windows.h> you will get an undefined reference. Please include the corresponding header file.

4) How do I call an external program from the IDE?

In the 'Options' menu there is an option 'Add utility'. Use this.

5) How can I determine in which library the function 'xxx' is located?

Go to the 'Search' menu bar and start GREP. Type the name of the function as the pattern to search, and give the \lcc\include\*.exp file pattern. This will find which .exp has this function defined in it (if at all). Then add that library to the link command line.

6) How do I generate an import library for my DLL?

Build a text file containing:

 

MYDLL.dll

 

 

_foo@12

foo

 

_linelength

linelength

data

_alternatefoo@12

foo

 

This file should contain the name of the DLL in the first line, then a series of exports. In the first column you should write the name of the function, as decorated by the compiler: A leading underscore, and a '@nn' for all _stdcall functions. The number following the @ means the number of arguments * 4. In the second column, you should write the name as it was exported from the DLL. This is optional. If absent, the buildlib utility will use the name of the function minus the decorations. The third column (optional) is only necessary if you want to export a data item and not a function.

You can build aliases (alternatefoo and foo are different names for the same DLL entry point).

7) Why is my executable so big?

Do not forget to instruct the linker to eliminate the debug information.

8) How do I pass command line parameters to my program when I use the debugger?

Use the ‘Debugger’ tab in the ‘Configuration’ options.

9) How do I start the debugger with a given executable without building a project?

At the command line enter:

Wedit myprogram.exe <optional arguments>

or use the ‘File->Open menu’ option, and enter the name of the executable you want to debug.

10) Why does my program crash when I change the 'Optimize' option?

This can be a problem in the compiler, but before blaming the compiler, remember the following:

·When optimizing, the compiler does not initialize local variables to known 'bad' values, as it does when compiling in a normal setting with debugging info. If you use an uninitialized variable then, in a normal compilation the program will crash.

·Tighter memory layout and register usage when optimizing can produce different behavior when uninitialized variables are used.

·The ASSERT macro can contain code with side effects. If those side effects are not being compiled because the ASSERT macro is not active in an optimized version, those side effects are not there in the optimized build, which can provoke different program behavior.

11) How do I obtain a stack trace when my program crashes?

Compile all modules with the -g4 option or set the corresponding option in Wedit.

12) How do I use an MSVC import library with lcc?

You can use the "Import foreign library" in the "Utils" menu of the IDE. That option does essentially the following actions:

1.Use the pedump utility to build an ASCII .exp file from the library.

2.Use the buildlib utility to build a library from the generated exp file.

Example:

d:\lcc\test> pedump /EXP qprowinm.lib >qprowinm.exp

d:\lcc\test> buildlib qprowinm.exp qprowinl.lib

The first line instructs pedump to generate a file suitable for the buildlib utility. In the first line, the generated file should contain the name of the DLL to which this import library is referring. If that name does not appear, it is highly probable that this is NOT an import library, but a normal library that should work without any problems with lcc.

The second line instructs the buildlib utility to use the generated qprowinm.exp to build an import library using the lcc format. If the name of the DLL was not found, this step will fail.

13) How do I list the exported symbols from an object file/executable file/DLL?

Use pedump with the following arguments:

pedump /exp <filename>

14) What is the difference between lcc 4.1 and lcc-win32?

Lcc 4.1 is a continuation by Dave Hanson and Chris Fraser of their work with the original LCC compiler. Lcc-win32 is derived from lcc 3.6 and has diverged considerably since. The purposes of the two systems are quite different.  Lcc 4.1 needs MSVC to run and is not very well adapted to the Windows environment. It is conceived as an environment to learn how a cross compiler works and can generate code for a wide spectrum of machines. Lcc-win32 is a stand alone compiler system, requiring nothing else. It is limited, however, to the Windows/x86 environment and is not a cross compiler.

15) The wizard stops with 'Code generation fails' in my Windows 95 system. What should I do?

In some older Windows 95 systems, the wizard fails mysteriously. I have spent a lot of time tracking this and never was able to determine why. When I call the PropertySheet primitive, in some systems the answer will be minus one, and nothing will be shown. This problem disappears with a newer version of the system. I am sorry about this, but there is nothing that can be done. You must acquire the latest service release and upgrade your system.

16) How do I build a DLL?

There are several ways of doing this.

·        You can use the integrated development environment, specifying explicitly the ‘DLL’ option. This is the easiest.

·        You can call up the ‘wizard’ and generate the DLL skeleton of your DLL with it. You specify to the wizard in its dialog boxes where on your disk you want the code to be written.

·        You can link your program using the –DLL option, without forgetting to specify the .def if necessary. This assumes you work from the command line.

14) What does it mean “compiler error in kids” ? 

This means that the compiler has found a combination of operations that it does not know how to generate. This error can occasionally appear when you are using the long long integers. This data type has been introduced relatively recently, and there may be some combinations of operations that are still not possible. In the event that you get this message, please send me a bug report.

 

15) How can I use the debugger of lcc with Microsoft’s compiler?

You should compile with the debug information set to the standard NB09 and avoid the program database. This can be accomplished with the following command line to the Microsoft compiler ‘cl’:

cl /Z7 foo.c /link /pdb:none

16) When I start my program, a ‘DOS box’ (console) appears. How can I get rid of it?

You have not defined your program as a Windows (GUI) program. To do this, go to the ‘Linker configuration’ tab, and check the ‘Windows program’ radio button. This will add the option ‘Subsystem Windows’ to the linker command line.

When Windows starts a program, it looks at its header for the ‘Windows’ bit. If the program is not marked as a GUI program, it will open a console window before starting it. The linker defaults to a ‘console’ application, and not to a Windows application.

17) The linker indicates that _LibMain@12 is not defined when I try to link my DLL. What does this mean and how do I get rid of it?

  This means you did not define the entry point of your DLL. Generate a DLL skeleton with the wizard. Or write the following function:

BOOL WINAPI __declspec(dllexport) LibMain(HINSTANCE hDLLInst,DWORD fdwReason,LPVOID lpvReserved)

{

       return 1;

}

18) How do I print a message to be shown in the debugger?

With the OutputDebugString() function. If the application has no debugger, the system debugger displays the string. If the application has no debugger and the system debugger is not active, OutputDebugString does nothing.

19) How do I debug a DLL?

The debugger cannot start a DLL like a normal executable. You have to define an executable that will be started by the debugger. This executable should be linked with the import library of your DLL, and should contain debug information. When this is done, Wedit will trace calls into the DLL in exactly the same manner as it will trace calls into any other function. This will work too if the DLL is loaded with LoadLibrary, instead of being linked in the executable. The drawback of the LoadLibrary method is that breakpoints cannot be re-established, since Wedit has no way to know which DLLs the program will dynamically load.

20) My dialog box does not show up in the screen!

This can happen if you have a control defined in ComCtl32.dll, and you did not call InitCommonControlsEx. When you use one of the controls in that DLL, you have to call that function before you make the call to DialogBox. If you fail to do that, Windows will not find the class of the list view, slider, etc., and it will refuse to load the entire dialog box. A sample code for how to do that is:

INITCOMMONCONTROLSEX icex;

memset(&icex,0,sizeof(icex));

icex.dwSize = sizeof(icex);

icex.dwICC = ICC_DATE_CLASSES; // The month calendar control will be added.

InitCommonControlsEx(&icex);

 

21) How do I send a bug report?

The purpose of a bug report is to allow the lcc developers to reproduce the bug so that they can understand it and then correct it. In this context, it is of paramount importance that the error report states clearly the symptoms of the error and the code that produces this error. If you write things such as: ‘It does not work’ or ‘It writes an error message’, there will be NO WAY to help you, since we will NOT be able to reproduce the error or find out what is really not working !

You should specify what the actions were that produced a crash, if you were working within the IDE. Then you should specify the symptoms you see (error message, etc.). If the error is produced by a sequence of C code, try to find out what the smallest piece of code is that reproduces the bug. It is impossible to find out what is not working if we receive a bunch of C files with the comment: This does not work.

Send your bug reports to:

Jacob@jacob.remcomp.fr