467,161 Members | 999 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

[VS 2005] Custom Build Step problem in C++

Hi all,

Sorry for the repost, but I never received any response when I first
asked this a few weeks ago. I would really appreciate some feedback on
this, it's driving me nuts...

I'm beginning the process of moving some projects from VS.Net 7 to
VS2005. I'm having problems getting a Custom Build Step to work.

In the dialog for the header file I want to perform the custom step on,
I copy and paste the command line:
$(QTDIR)\bin\moc.exe "..\Messenger.h" -o ".\moc_Messenger.cpp"

I also set description, outputs, additional dependencies
($(QTDIR)\bin\moc.exe), and click Ok. I can open the dialog up again,
and see all the options as I set them.

However, when I do a build, it fails, with moc.exe complaining of
invalid arguments. When I check the Command Line entry in the Custom
Build Step properties again, it now contains:
$(QTDIR)\bin\moc.exe -DQT_NO_DEBUG -D_WINDOWS -DUNICODE -DWIN32
-DQT_DLL -DQT_THREAD_SUPPORT -I"$(QTDIR)\include" -I"."
-I"d:\Qt\3.3.2\mkspecs\win32-msvc.net" "..\Messenger.h" -o
".\moc_Messenger.cpp".

I can remove the '-DQT_NO_DEBUG -D_WINDOWS -DUNICODE -DWIN32 -DQT_DLL
-DQT_THREAD_SUPPORT -I"$(QTDIR)\include" -I"."
-I"d:\Qt\3.3.2\mkspecs\win32-msvc.net', compile, get the error, repeat
ad naseum.

Is there some option somewhere in VS2005 that is causing it to add the
defines and includes to the command line for a CBS? I never experienced
this in VS 7.

Thanks, Michael
Sep 19 '06 #1
  • viewed: 2098
Share:
1 Reply
Michael Russell wrote:
Hi all,

Sorry for the repost, but I never received any response when I first
asked this a few weeks ago. I would really appreciate some feedback
on this, it's driving me nuts...

I'm beginning the process of moving some projects from VS.Net 7 to
VS2005. I'm having problems getting a Custom Build Step to work.

In the dialog for the header file I want to perform the custom step
on, I copy and paste the command line:
$(QTDIR)\bin\moc.exe "..\Messenger.h" -o ".\moc_Messenger.cpp"

I also set description, outputs, additional dependencies
($(QTDIR)\bin\moc.exe), and click Ok. I can open the dialog up again,
and see all the options as I set them.

However, when I do a build, it fails, with moc.exe complaining of
invalid arguments. When I check the Command Line entry in the Custom
Build Step properties again, it now contains:
$(QTDIR)\bin\moc.exe -DQT_NO_DEBUG -D_WINDOWS -DUNICODE -DWIN32
-DQT_DLL -DQT_THREAD_SUPPORT -I"$(QTDIR)\include" -I"."
-I"d:\Qt\3.3.2\mkspecs\win32-msvc.net" "..\Messenger.h" -o
".\moc_Messenger.cpp".

I can remove the '-DQT_NO_DEBUG -D_WINDOWS -DUNICODE -DWIN32 -DQT_DLL
-DQT_THREAD_SUPPORT -I"$(QTDIR)\include" -I"."
-I"d:\Qt\3.3.2\mkspecs\win32-msvc.net', compile, get the error, repeat
ad naseum.

Is there some option somewhere in VS2005 that is causing it to add the
defines and includes to the command line for a CBS? I never
experienced this in VS 7.
I'm not aware of any switch - but I suspect that the problem lies in the
fact that .h is an extenion that the IDE recognizes, so it's "helping" you.
Would it be possible to use a different extension for this file - one that
the IDE doesn't know anything about?

You might want to look into the features in VC2005 that allow you to define
your own build tools (based on file extension) so you don't have to worry
about writing custom build steps. Finding the options in the help is rather
torturous, but...
In the solution explorer, right-click on your C++ project and choose "Custom
Build Rules..." from the context menu.
On the dialog that appears, click "New Rule File...".
Give your new rule file a name, like "Run MOC"

.... and so on. It's a bit more involved than one might hope (but it's also
pretty powerful). See

http://msdn2.microsoft.com/en-us/library/03t8bzzy.aspx

as a starting point.

-cd
Sep 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Peter Ritchie | last post: by
5 posts views Thread by Steve Le Monnier | last post: by
10 posts views Thread by WT | last post: by
2 posts views Thread by prabhupr@hotmail.com | last post: by
7 posts views Thread by ashley.ward@gmail.com | last post: by
reply views Thread by Michael Russell | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.