Suppose there is an under linux lib, are separately compiled into dynamic and static libraries , assumed libtest.so and libtest.a, was put in the same directory .  
 Qt applications now want to link to the static library , that libtest.a.  
 In . pro file inside with LIBS + =-ltest, the default , then link to the dynamic library libtest.so go up.  
 How to specify it to make it link to a static library up it ? ?  
  
 
 ------ Solution ------------------------------------ -------- 
 LIBS + = / path / to / libtest.a  
  
 
 ------ eference ------------------------------------ --- 
 try using an absolute path 
 ------ eference ----------------------------- ---------- 
 
 you are referring to  
 LIBS + = libtest.a  
 do ? 
 ------ eference --------------------------------------- < br> there are two options to do static link . one is to do a static link only supports the sdk  
  
 The second is to use the following method to write . pro file  
   TARGET = YourProjectName 
 TEMPLATE = app 
 SOURCES + = main.cpp window.cpp 
 HEADERS ; + = window.h   
 followed by such content  
  
   CONFIG + = static 
 static {/ / Everything below takes effect with CONFIG + = static < br />}  
 ------ eference -------------------------------- ------- 
 
  
 Sorry, I do not use static lib qt problems arising . But this static lib has already done , qt program wants to link to this static lib when arise. 
 ------ eference --------------------------------------- < br> GOOD!!  
 THAT WORKS!  
 THANKS-darkdong.  
  
 
 ------ eference ------------------------------------ --- 
 then the above problem , an existing non- qt program static link to libtest1.a, while libtest1.a it has static link to libtest2.a, the non- qt program can properly build through .  
 But a qt program linking process is the same , but in the process of being given link . . . The following error:  
 undefined reference to 'XXX'  
 XXX are libtest2.a in export out of the function .  
 I ask this is probably what causes it , the windows below you can compile, that is not under linux . . 
 ------ eference --------------------------------------- < br> What a coincidence , I have encountered this problem. Now resolved, thank you , 4th Floor answer. 
 ------ eference --------------------------------------- < br> Hello , what is your problem solved? I QT (windows) also encountered the same problem , lib2 dependent on lib1, but using LIBS + = libtest.a methods are added, compile-time prompt lib2 undefined number of variables , and these variables are in fact already in lib1 definition.  
 hope to ask this question .  
  
  
 
 ------ eference ------------------------------------ --- 
 why I use absolute paths link does not work it, I have a non- qt algorithm library, a qt interface library uses the algorithm algorithm library , a command line interface and then re- program call interface library function , in the final command line interface program links being given that algorithm library fftw used in the function can not find , how do I fix it ? Tried many ways will not work, no problem in the windows program 
没有评论:
发表评论