LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-06-2004, 07:39 AM   #1
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Rep: Reputation: 31
vim and makefile


:set makeprg=make
:make
shell returned 2
(1 of 1): make: *** No targets specified and no makefile found. Stop.

Ok, I have a directory which has Makefile and source code file so when in the directory ( with console ), you could just type make to produce the binary. But how can I do that with vim?

Second question:
How could u compile single program with vim?
Assume in console, you do this:
g++ -o bla bla.cpp

Now you are editing bla.cpp, but you want to compile it with vim. How do you do that?
 
Old 06-06-2004, 08:03 AM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
Quote:
Now you are editing bla.cpp, but you want to compile it with vim. How do you do that?
Uh, VIM is a text editor, not a compiler
 
Old 06-07-2004, 03:30 AM   #3
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Quote:
Uh, VIM is a text editor, not a compiler
Uh, vim is actually a full-blown IDE.

If the Makefile is working you should be able to just type :make in vim to compile it. This of course assumes that your current working directory is the one where the Makefile is located (this works just fine for me, I just verified it with a simple program). The error message seems to hint at you might not be in that directory.

To set the compiler and options for a simple c file (as an example), try this: :set makeprg=gcc\ -Wall\ -o\ outname\ %
The backslashes are necessary to escape the spaces, and the % character refers to the filename you are currently editing. So The above translates to gcc -Wall -o outname whatever.c.
When you have set your makeprg as you wish you can compile using make and show the error list with :cl, hop to the next error line using :cn and so on.

Hope that helps.

Håkan
 
Old 06-07-2004, 09:04 AM   #4
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Original Poster
Rep: Reputation: 31
Ok, that works. But I have to launch vim from the source code directory with console. But usually I launch gvim with icon then I open the source code file and the current directory is not source code directory. That means I cannot use "make" command anymore because the current directory is in $HOME directory ( I think ).

How to change the current directory in vim?
 
Old 06-07-2004, 02:03 PM   #5
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Heh, I had to check it for myself but this works:
:cd /wherever/the/directory/is
:make



Håkan
 
Old 06-09-2004, 07:20 AM   #6
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Original Poster
Rep: Reputation: 31
Ok, thank you. But that means I miss GTK+-2.4 feature, that is bookmark of GTK+ file selection. But nothing is perfect in this world.

But how can you run the binary?
:./a.out
:a.out
not working.......
 
Old 06-09-2004, 07:47 AM   #7
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
To execute external commands you need to prepend them with an exclamation mark. :!./test to execute the program "test" located in the current directory.

I don't understand what you mean with the GTK+ bookmark at all.


Håkan
 
Old 06-10-2004, 12:16 AM   #8
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Original Poster
Rep: Reputation: 31
If you use GTK+-2.4 version, when you open file with gvim, you have bookmark feature. So you could record what directory are visited very often by you.

But thank you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vim not putting tabs in Makefile sarin Programming 6 01-15-2018 12:58 PM
encryption with Vim (vim -x) mikshaw Linux - Software 2 03-07-2007 09:00 AM
How to modify makefile.in or makefile.am QiangWan Linux - Newbie 1 05-17-2005 11:07 AM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration