May 11, 2012

urgentDiplomacy urgentDiplom..
Lab Rat
3 posts

[solved] PRO function calls

 

Hello,

I am developing on 64bit Win7 and am trying to figure out why a

  1. system(cd $$mydir)

call in my .pro file is not working. I have tried hard coding the path

  1. system(cd C:/)

changing the cd call to chdir and even trying different combinations of parenthesis and still have issues. Here is my stub:

  1. #-------------------------------------------------
  2. #
  3. # Project created by QtCreator 2012-05-11T11:47:17
  4. #
  5. #-------------------------------------------------
  6.  
  7. QT       += core
  8.  
  9. QT       -= gui
  10.  
  11. TARGET = test
  12. CONFIG   += console
  13. CONFIG   -= app_bundle
  14.  
  15. TEMPLATE = app
  16.  
  17.  
  18. SOURCES += main.cpp
  19.  
  20. system(cd C:/)
  21. system(dir)

This setup seems to work fine on Linux (with the appropriate changes to mydir and dir call). Is this a known compatibility issue? I have not found any documented forms of it…

5 replies

May 11, 2012

Tobias Hunger Tobias Hunger
Mad Scientist
3383 posts

I do not think changing directories is a good idea in qmake. What do you want to do?

May 11, 2012

urgentDiplomacy urgentDiplom..
Lab Rat
3 posts

I have some code generation scripts that need to run on compilation in another directory, normally I would readjust the way the script executes but this is a part of a much larger project and editing the script may destabilize other coder’s projects. I cannot really make this a ‘one-off’ solution unfortunately.

May 11, 2012

1+1=2 1+1=2
Robot Herder
638 posts

urgentDiplomacy wrote:
Hello,

This setup seems to work fine on Linux (with the appropriate changes to mydir and dir call).

I don’t know why you think this works on Linux. IMO, this should fail under any OS. As the command passed to system() will run in another process.

May 15, 2012

Volker Volker
Ant Farmer
5428 posts

If you’re not able to change the original scripts, I would write wrapper script that takes the desired directory as argument, changes directory to it and calls then calls the original script.

May 15, 2012

urgentDiplomacy urgentDiplom..
Lab Rat
3 posts

Thanks Volker and Herder for your help! I should have said that some people on my project believe that it works in linux but it doesn’t for the reasons you specified Herder.

[SOLVED] thanks to Herder.

 
  ‹‹ Qt Creator’s MSVC2010 debug compiler didn’t work with OpenCV in Windows system      Where does Qt Help within Qt Creator stores its bookmarks? ››

You must log in to post a reply. Not a member yet? Register here!