[GRADLE-2923] Files with identical names in C/C++ source tree are silently excluded from compilation. Created: 16/Oct/13  Updated: 13/Mar/14  Resolved: 13/Mar/14

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.12-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: René Gröschke (Inactive)
Resolution: Fixed Votes: 3


I've ran into a problem that appears when a native build tree contains source files with same name placed in different directories. It appears that Gradle directs compilation output for the whole tree into a single directory and names of the object files come into clash.

Here's the example tree:

├── build.gradle
└── src
└── main
└── cpp
├── foo1
│ ├── foo.cpp
│ └── foo.h
├── foo2
│ ├── foo.cpp
│ └── foo.h
└── main.cpp

Files `foo.h` and `foo.cpp` under subdirectories `foo1` and `foo2` declare and define functions `foo1()` and `foo2()`; both are called from `main.cpp`. The build.gradle just defines the executable:

apply plugin: 'cpp'

executables {
main {}

When `gradle mainExecutable` is called, linker shows undefined reference to `foo2()`, even though compilation step went smoothly. Is there a way to solve that without renaming files? It's not always possible or desirable.

Comment by Julien Jean Paul Sirocchi [ 13/Mar/14 ]

This bug bit me in my mixed Java/Scala project. Initially, it was my belief that it was a problem with the Scala plugin but having found this issue I guess that assumption was wrong.
+1 to get this fixed asap, it happens often also in Scala-land to have filenames (not traits/classes/objects) that might clash w/ Java filenames.

Here's an example: https://github.com/sirocchj/name-clash

Comment by René Gröschke (Inactive) [ 13/Mar/14 ]

At Julien,
I fixed this issue already but this fix won't target your issues with java/scala. I'll have a look at your example later.


Generated at Wed Jun 30 12:35:06 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.