as为什么在choose library dependencypp助手找不到library依赖包

c++ - Makefile updated library dependency - Stack Overflow
Insights on the world's developers
Demographics. Technologies. Salaries. Career satisfaction.
I have a large makefile which builds several libraries, installs them, and then keeps on building objects which link against those installed libraries.
My trouble is that I want to use "-lfoo -lbar" as g++ flags to link against the two installed libraries, but the dependencies get messed up.
If I change a header "42.h" which the library foo depends on, then of course make will rebuild and install it, but it does not appear to notice that my object "marvin" used "-lfoo" and marvin is left linked against the old version...
Thus far, I've been doing:
$(myObject): $(localSrc) /explicit/path/to/lib/libfoo.a
$(CXX) $(CPPFLAGS) $(INCFLAGS) -o $@ $^ $(LINKFLAGS) $(LINKLIBS)
But I'm at a point where this is no longer a viable option.
I need to simply add libraries "-lfoo -lbar" to the LINKFLAGS variable and have the linker figure things out?
In the mean time, I've aliased a few commands to explicitly blow away the object file(s) in question and then call make, but this is getting silly.
I'm pressed for time, but if necessary I could post a small example perhaps Friday evening or Saturday morning.
Hence, I feel like I'm back in some bad version of windows dll hell.
Is there something I can do to make the linker take notice of the version of the libraries that an object was built against and relink it if those libraries change??
Updated: So I hadn't had a chance to crash the suggestions until now.
The drawback of what I'm doing is using static libraries.
So I can't use ldd.
So I rewrote my Makefile and found a way around this problem.
If I get time, I'll post what I did.
5,58253357
As far as I know, make in general isn't very good at automatically detecting dependencies like this.
(It's not really make' make is a higher-level tool that's not aware of the specifics of the commands that it's spawning or what those commands do.)
Two options come to mind.
First, you could run ldd on $(myObject), save its list of libraries to a text file, then feed that back into your makefile as a list of dependencies.
(This is similar to using -MD to save a list of header files to a text file then feeding that back into the makefile as additional rules for source file compilation, as Sam Miller suggested.)
Second, you could use a LINKLIBS variable as you've been using, and use GNU Make's
to let the same variable work for both dependencies and command-line options.
For example:
LINKLIBS := /explicit/path/to/lib/libfoo.so
$(myObject): $(localSrc) $(LINKLIBS)
$(CXX) $(CPPFLAGS) $(INCFLAGS) -o $@ $^ $(LINKFLAGS) $(patsubst %,-l:%,$(LINKLIBS))
36.3k1483156
How about this:
LIBS = foo bar blah # and so on
LINKFLAGS = $(addprefix -l,$(LIBS))
LIBPATHS = $(patsubst %,/explicit/path/to/lib/lib%.so, $(LIBS))
$(myObject): $(localSrc) $(LIBPATHS)
$(CXX) $(CPPFLAGS) $(INCFLAGS) -o $@ $^ $(LINKFLAGS) $(LINKLIBS)
58.6k682113
You might try the gcc dependency generation arguments like -MD, it's not clear to me if you are using them.
18.9k34777
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .25527
Stack Overflow works best with JavaScript enabledEclipse中m2e插件构建web项目的步骤
Maven工具构建web项目再导入Eclipse的步骤
[一]、Eclipse中m2e插件构建web项目的步骤
第一步:创建项目,按照 New –&
FIle –& Other –& Maven –& MavenProject :
第二步:选择项目存放路径:
第三步:选择项目类型 Archetype
第四步:填写项目基本信息
第五步:修改为web类型项目,配置content directory:
第六步:配置Maven lib依赖问题,解决Run on Server时lib找不到的问题:
方法一:图像界面:
方法二:修改配置文件 .classpath:
把配置文件中 classpathentry 节点的内容从原来的:
&classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"&
&/classpathentry&
&classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"&&/classpathentry&
修改成如下:
&classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"&
&attributes&
&attribute name="org.ponent.dependency" value="/WEB-INF/lib"/&
&/attributes&
&/classpathentry&
&classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"& &attributes&
&attribute name="org.ponent.dependency" value="/WEB-INF/lib"/& &/attributes&&/classpathentry&
然后执行 Run on Server 即可。
[二]、Maven工具构建web项目再导入Eclipse的步骤
以 WORKSPACE=D:\workspace_sun\maven-demo\ 为工作目录
第一步:创建项目
按 win+R 输入cmd 回车进入控制台界面,运行如下命令:
mvn archetype:create -DgroupId=com.micmiu.maven.demo -DartifactId=maven-web-demo2 -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
mvn archetype:create -DgroupId=com.micmiu.maven.demo -DartifactId=maven-web-demo2 -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
创建完成后的基本目录结构如下:
├─resources
└─webapp
└─WEB-INF
│&&pom.xml│└─src&&&&└─main&&&&&&&&├─resources&&&&&&&&└─webapp&&&&&&&&&&&&│&&index.jsp&&&&&&&&&&&&│&&&&&&&&&&&&└─WEB-INF
第二步:转为Eclipse项目
在控制台执行如下命令:
mvn eclipse:eclipse -Dwtpversion=1.0
mvn eclipse:eclipse -Dwtpversion=1.0
转化后的目录结构如下:
.classpath
├─.settings
.component
org.mon.project.facet.core.xml
├─resources
└─webapp
└─WEB-INF
└─target
└─classes
12345678910111213141516171819
│&&.classpath│&&.project│&&pom.xml│├─.settings│&&&&&&.component│&&&&&&org.eclipse.wst.common.project.facet.core.xml│├─src│&&└─main│&&&&&&├─resources│&&&&&&└─webapp│&&&&&&&&&&│&&index.jsp│&&&&&&&&&&││&&&&&&&&&&└─WEB-INF│&&&&&&&&&&&&&&&&&&web.xml│└─target&&&&└─classes
然后按照 Import… –&
Maven –&
Exiting Maven Projects 导入Eclipse即可.
第三步:同样按照上面的方法配置Maven lib依赖问题,解决Run on Server时lib找不到的问题。
tips:如果在转化为Eclipse项目之前,修改好 pom.xml 文件中的所有lib依赖关系,再转为eclipse项目导入到eclipe中,这样也可以解决部署时lib文件找不到的问题。
本文介绍到此结束@.
原创文章,转载请注明: 转载自[
本文链接地址:
- 118,435 views - 85,420 views - 47,228 views - 43,316 views - 38,101 views - 36,700 views - 32,748 views - 29,310 views - 20,695 views - 20,657 views
2015年八月 &(1)
2015年三月 &(5)
2015年二月 &(3)
2015年一月 &(12)
2014年十二月 &(4)
2014年十一月 &(3)
2014年七月 &(1)
2014年五月 &(1)
2014年四月 &(12)
2014年三月 &(4)
2014年二月 &(6)
2014年一月 &(8)
2013年十二月 &(1)
2013年十月 &(9)
2013年九月 &(7)
2013年八月 &(8)
2013年六月 &(4)
2013年五月 &(4)
2013年四月 &(3)
2013年三月 &(10)
2013年二月 &(1)
2013年一月 &(2)
2012年十二月 &(1)
2012年十一月 &(7)
2012年十月 &(2)
2012年九月 &(4)
2012年八月 &(13)
2012年七月 &(14)
2012年六月 &(12)
2012年五月 &(15)
2012年四月 &(20)
2012年三月 &(22)
2012年二月 &(86)
标签云(3D)
WP Cumulus Flash tag cloud by
9 or better.Why can't I find com.android.support:design:22.2.0 in Choose Library Dependency in Android Studio? - Stack Overflow
Insights on the world's developers
Demographics. Technologies. Salaries. Career satisfaction.
I hope to use Snackbar in Android Studio, I have read .
So I add compile 'com.android.support:design:22.2.0' in build.gradle. Snackbar.make(...) works well.
I open Projec Structure in Android Studio, I think I can find the com.android.support:design:22.2.0 item in Choose Library Dependency UI, but in fact the item isn't be listed, why?
BTW, I have updated my Android.
Choose Library Dependency Screenshot
Updated Screenshot
build.gradle
apply plugin: 'com.android.application'
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "info.dodata.messagecleanup"
minSdkVersion 9
targetSdkVersion 22
versionCode 9
versionName "1.09"
archivesBaseName = "MessageCleanup-V" + versionName
buildTypes {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.support:design:22.2.0'
Snackbar.make(mView, "Hello SnackBar!", Snackbar.LENGTH_SHORT)
.setAction("Undo", new View.OnClickListener() {
public void onClick(View v) {
// Perform anything for the action selected
Toast.makeText(mContext, "I click Undo",Toast.LENGTH_LONG).show();
Open SDK Manager, then update Android Support Library, Android Support Repository to latest
Config AndroidManifest.xml with compileSdkVersion > = 22 , buildToolsVersion >= 22 (because design library only supports API >= 22)
Open sdk\extras\android\m2repository\com\android\support to know exactly the revision we have now
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
Note that we need to add two libraries with the same revision (22.2.0 or ...)
build successful
10.8k112847
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .25527
Stack Overflow works best with JavaScript enabledAdd github library as dependency to Android-Studio project [添加github库依赖Android-Studio项目] - 问题-字节技术
Add github library as dependency to Android-Studio project
添加github库依赖Android-Studio项目
问题 (Question)
I am trying to implement ActionBar-PullToRefresh from . I just made the switch from Eclipse to Android-Studio so I am totally new to AS and Gradle.
chrisbanes writes on the site:
The easiest way to add ActionBar-PullToRefresh to your project is via
Gradle, you just need to add the following dependency to your
build.gradle:
dependencies {
mavenCentral()
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
Does this mean that I don't have to download the library and Gradle takes care of it so that I always have the latest version? I just don't know where to put the above line. I have two gradle.build files one in my root that looks like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
and the one in my project which looks like:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
compileSdkVersion 19
buildToolsVersion "19.0.1"
sourceSets {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/&type&
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/&type&/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
Do I have to add a repository somewhere?
我试图实施ActionBar-PullToRefresh。我刚从Eclipse使开关Android-Studio所以我全新的和它。chrisbanes在网站上写道:ActionBar-PullToRefresh添加到您的项目的最简单方法是通过Gradle,你只需要添加以下依赖build.gradle:dependencies {
mavenCentral()
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
这是否意味着我不需要下载图书馆和Gradle照顾它,让我总是有最新的版本吗?我只是不知道去哪里把上面的线。我有两个gradle。构建文件在我的根,看起来像:// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
和我在一个项目看起来像:apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
compileSdkVersion 19
buildToolsVersion "19.0.1"
sourceSets {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/&type&
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/&type&/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
我需要添加一个存储库的某个地方吗?
最佳答案 (Best Answer)
It will work when you put this line in your project build.gradle, in the dependencies section:
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
Also, add:
repositories {
mavenCentral()
repositories {
mavenCentral()
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
Gradle will download the needed resources automatically for you.
它将工作当你把这条线在您的项目build.gradle,在dependencies部分:compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
本文翻译自StackoverFlow,英语好的童鞋可直接参考原文:匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。}

我要回帖

更多关于 library dependency 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信