首页 \ 问答 \ Makefile错误 - 链接器输入文件未使用(Makefile Error - Linker input file unused)

Makefile错误 - 链接器输入文件未使用(Makefile Error - Linker input file unused)

我正在尝试运行一个看起来像这样的简单makefile:

T=-ansi -pedantic -Wall -Werror
a.out: test.o extra.o
    gcc $(T) -c test.o extra.o

test.o: test.c test.h 
    gcc $(T) -c test.c

extra.o: extra.c extra.h 
    gcc $(T) -c extra.c

clean:
    rm *.o a.out

但我似乎得到警告告诉我“链接器输入文件未使用,因为链接未完成”

我尝试在gcc之后从a.out指令中删除“-c”,但这会产生更多问题。 我不确定如何从这里开始,任何想法/输入将非常感激。

编辑:我正在通过“make -T”运行程序,同时从a.out中删除-c,导致错误“无效符号索引”


I'm trying to run a simple makefile that looks like this:

T=-ansi -pedantic -Wall -Werror
a.out: test.o extra.o
    gcc $(T) -c test.o extra.o

test.o: test.c test.h 
    gcc $(T) -c test.c

extra.o: extra.c extra.h 
    gcc $(T) -c extra.c

clean:
    rm *.o a.out

But I seem to be getting warnings telling me that "linker input file unused because linking not done"

I tried removing the "-c" from the a.out directive, after the gcc, but that produced to give me more problems. I'm not sure how to go about proceeding from here, any ideas/input would be much appreciated.

EDIT: I'm running the program by "make -T", also removing the -c from a.out, causes the error" invalid symbol index"


原文:https://stackoverflow.com/questions/33137876
更新时间:2022-05-06 06:05

最满意答案

您的问题中的代码看起来是线程安全的,因为:

  • Class Bar使用原子和线程安全的AtomicLong
  • CopyOnWriteArraySet也是线程安全的(它在每次写操作时复制整个数组)。

所以这一切都是线程安全的,你不会得到ConcurrentModificationException ,并且这段代码的结果是可预测的,因为你迭代的集合实际上是不可变的。


The code in your question looks thread-safe because:

  • Class Bar uses AtomicLong which is atomic and thread-safe.
  • The CopyOnWriteArraySet is thread-safe as well (it copies whole array on every write operation).

So it all is thread-safe, you will not get ConcurrentModificationException, and the result of this code is predictable, because the collection you iterate through is in fact immutable.

相关问答

更多
  • 它不是线程安全的。 请参阅此处的线程安全/不安全类的列表 It is not thread safe. See the list of thread safe/unsafe classes here
  • 听起来像读写器锁是必要的。 基本上,这个想法是,你可能有一个或多个读者或一个作家。 永远不可以同时拥有读写锁。 编辑:我认为适合您的设计的用法的一个例子涉及做一个小的改变。 为拥有该列表的类添加一个“迭代”函数,并将其设置为模板,以便可以传递函数/函数来定义每个节点要执行的操作。 像这样的东西(快速和脏的伪代码,但你明白了......): class A { public: ... void AddItem(const T& item, int index) { rwlock ...
  • 是的,没关系。 关键是你在迭代时,没有什么能够修改地图,因为cache.put最终会在cache上同步。 就个人而言,我宁愿通过使用“普通”散列图并同步来自所有三种方法的同一对象(无论是地图还是其他东西)来明确这一点 - 但你得到的应该没问题。 (或者,您可以使用ConcurrentHashMap开始。至少值得一看。) Yes, that's okay. The key thing is that while you're iterating, nothing will be able to modify ...
  • 是的。 它扩展了Random ,它始终具有事实上的线程安全实现,并且从Java 7中明确保证了线程安全性。 如果许多线程正在使用单个SecureRandom ,那么有可能会导致性能下降。 另一方面,初始化SecureRandom实例可能相对较慢。 是否最好分享全局RNG,或为每个线程创建一个新的RNG将取决于您的应用程序。 ThreadLocalRandom类可以用作模式来提供支持SecureRandom的解决方案。 Yes, it is. It extends Random, which was alwa ...
  • Groovy每个都使用下面的迭代器(参见DefaultGroovyMethods中的每个方法)。 因此,不,它们本身就不是线程安全的。 但你显然仍然可以在同步块中使用它们。 您可能也对@Synchronized AST转换感兴趣。 Groovy's each uses iterators underneath (see the each method in DefaultGroovyMethods). As such, no, they would not be thread-safe in and of ...
  • 以下实现线程是否安全? 这取决于您如何在代码中访问和修改MyObject实例,如果您始终使用此MyObject实例作为对象的监视器访问和修改同步块中的MyObject的给定实例,那么它将是线程安全的,否则它赢了是的。 你的put方法不是线程安全的,因为putIfAbsent和replace不是原子地执行的,这可能导致竞争条件问题 ,使用merge(K key, V value, BiFunction remappingFunction)来做完 ...
  • 那么,它甚至不会编译,因为你试图锁定一个值类型。 引入一个引用类型的单独锁定变量,例如 private static readonly object padlock = new object(); 除此之外: 如果StopBrowserCleaning()在有清理线程时(它正在休眠时)被调用,但是在第一个线程注意到它要关闭之前再次调用StartBrowserCleaning() ,则最终会有两个线程。 你可能想考虑有两个变量 - 一个是“是否意味着清理线程”,另一个是“实际上是否有清理线程”。 另外,如果 ...
  • 如果您只是阅读,并且未修改基础对象,列表和列表中的内容,则应该没有线程问题。 你实际遇到了什么问题? 我认为你可能会以某种方式修改LinkedHashMap。 更重要的是,你如何确定线程正在跳跃? 你确定你不只是看到混合的两个线程的输出,即使每个线程按顺序迭代,它们看起来像是跳来跳去吗? 例如,如果每个线程打印其当前条目,您可能会看到类似的内容 123 12 45 345 6 .... 这是顺序.... If you are only reading, and the underlying objects ...
  • 您的问题中的代码看起来是线程安全的,因为: Class Bar使用原子和线程安全的AtomicLong 。 CopyOnWriteArraySet也是线程安全的(它在每次写操作时复制整个数组)。 所以这一切都是线程安全的,你不会得到ConcurrentModificationException ,并且这段代码的结果是可预测的,因为你迭代的集合实际上是不可变的。 The code in your question looks thread-safe because: Class Bar uses Atomic ...
  • 我根本不会使用同步。 我会有一个循环,它将任务添加到ExecutorService。 ExecutorService es = Executors.newFixedThreadPool(nThreads); for(final MyType mt: myCollection) es.submit(new Runnable() { public void run() { doStuffWith(mt); } }); es.shutdown() ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)