newbie questions about setting up a new project

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 [1], 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! :slight_smile: 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 executable?

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.

Thanks,
- Joe

[1] http://www.llvm.org/releases/2.2/docs/Projects.html

Joe,

Joe Strout wrote:

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 [1], which describes how to set up a project in the LLVM way. But some things are still unclear to me.

Is the tutorial you're referring to the Projects.html page, or something different? And what OS are you using?

Sam

Is the tutorial you're referring to the Projects.html page, or something different?

I was referring to <http://www.llvm.org/docs/tutorial/JITTutorial1.html&gt;, but laboring under the belief that it would first be a good idea to first get through GettingStarted.html, which recommends putting your stuff under "projects" based on "sample", and led me to Projects.html.

I'm still stuck on that whole "projects" business -- the sample in my build directory doesn't match the description on Projects.html, but "make" works (apparently referencing source files under llvm-2.2/projects); and the one under llvm-2.2 matches the description and contains source files, but "make" there doesn't work.

However, after looking at the tutorial again, I realized that it doesn't matter -- I don't need a complex file hierarchy or even a Makefile; Owen provides a one-liner to compile and link the tutorial code at the bottom of the page. This works fine for me, regardless of where I put the source file.

So, while I still think the projects/sample issue is a confusing stumbling block, I'm willing to ignore it for now and presume that deeper understanding will come later.

  And what OS are you using?

OS X 10.4.11.

Best,
- Joe

Joe Strout wrote:

However, after looking at the tutorial again, I realized that it doesn't matter -- I don't need a complex file hierarchy or even a Makefile; Owen provides a one-liner to compile and link the tutorial code at the bottom of the page. This works fine for me, regardless of where I put the source file.

Yes, this is exactly what I was going to recommend. I haven't made a project like you are trying to do; maybe someone else can help you with that. But the tutorials you've found are great, and, as you've discovered, it doesn't take much to get them running.

Good luck!

Sam