[LLVMdev] newbie question regarding llvm-mingw

Ralf Schneider ralfs72 at googlemail.com
Wed Apr 30 16:57:28 PDT 2008


´╗┐Hello,

I'm playing around with the llvm-tools.

On linux everything worked as expected: I downloaded and compiled the
llvm-source. Assembled (llvm-as) and linked (llvm-ld) a hello_world
program and executed it successfully.

For windows I have downloaded the compiled mingw32-binaries:
http://llvm.org/releases/2.2/llvm-2.2-x86-mingw32.tar.bz2

I used the following hello_world program from the documentation:

hello_world.ll:
----------------------------------------------------------------------------------
; Declare the string constant as a global constant...
@.LC0 = internal constant [13 x i8] c"hello world\0A\00"          ; [13
x i8]*

; External declaration of the puts function
declare i32 @puts(i8 *)                                            ;
i32(i8 *)* 

; Definition of main function
define i32 @main() {                                                 ;
i32()* 
        ; Convert [13x i8 ]* to i8  *...
        %cast210 = getelementptr [13 x i8 ]* @.LC0, i64 0, i64 0 ; i8 *

        ; Call puts function to write out the string to stdout...
        call i32 @puts(i8 * %cast210)                              ; i32
        ret i32 0
}
´╗┐----------------------------------------------------------------------------------

I assembled it with: "llvm-as -f hello_world.ll"

If I try to run the bytecode with: "lli hellow_world.bc" - I get the
following error:

ERROR: Program used external function '__main' wich could not be
resolved!

I get the same error if I link the program with: "llvm-ld -v --stats
hello_world.bc -o hello_world.exe"
... and execute the resulting "hello_world.exe"

What I'm doing wrong?

And somehow related questions are:
Which external libraries gets automatically included during linking
(what are the dependencies) 
Only the standard c library? 
Is it possible to not include it?
Or link it static?
Is the behavior the same on all platforms?

I'm happy if someone can point me to a documentation regarding these
questions.

Thanks a lot for such a great compiler tool set!

- Ralf





More information about the llvm-dev mailing list