[LLVMdev] newbie questions about setting up a new project
joe at inspiringapps.com
Fri Mar 14 21:01:56 PDT 2008
I've downloaded and built LLVM 2.2, and I'm now trying to get to the
point where I can get through the first tutorial (which seems to
assume that you're already to the point of writing code and linking
against LLVM). I've found the Projects.html doc page , which
describes how to set up a project in the LLVM way. But some things
are still unclear to me.
(Please excuse my ignorance; I'm used to graphical IDEs and while
I've made simple Makefiles before, there doesn't seem to be anything
simple about integrating with the LLVM system.)
1. In the "Create a Project from the Sample Project" section, I'm
stuck on the third simple step, "Add your source code and Makefiles
to your source tree." If I knew how to do that, I wouldn't need the
sample! :) The sample includes literally half a dozen Makefiles (if
you include Makefile.common). Where exactly should I add "my"
Makefile, and what should that file contain?
2. Under "Source Tree Layout," I see that "For each program that you
build, you will have one directory in tools that will contain that
program's source code." OK, I only want to build one program, and I
see that the sample contains a tool subdirectory named "sample". So
I renamed that to "tutorial-1", and inside it, I find main.d and
main.o. What in the world is main.d? Can I just rename this to
main.cpp, replace its mysterious contents with C++ code, and expect
it to work?
3. Peeking at the Makefile inside tools/sample (now tools/
tutorial-1), the comments say that "sample is a dynamic library."
I'm not sure why that is useful; I want to run a program. Also,
quite curiously, there are no references at all that I can find to
main.d (which I would presume is the source file sample should be
built from). How would I go about modifying this to compile a gcc
file (which I'll write following the tutorial), and make an actual
4. With six different Makefiles lounging around in my project, which
one would I want to invoke in order to just build my little test
program? The one inside tools/tutorial-1, or the one in the project
root, or what? (The docs do say "Typically, you will want to build
your lib directory first followed by your tools directory" but it's
not clear to me how I would do that, nor why I would be typically
building libraries anyway.)
I think maybe I need a "tutorial 0" that walks me through the steps
of setting up my first project! Barring that, any tips you can
provide will be greatly appreciated.
Inspiring Applications, Inc.
More information about the llvm-dev