Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

390
Vistas
How to create C++ package using Swift Package Manager?

I'm following this blog to make a C++ package using SPM: http://ankit.im/swift/2016/05/21/creating-objc-cpp-packages-with-swift-package-manager/

But am getting this error when building:

swift build
'SwiftCpp' /home/karthik/Swift_programs/SwiftCpp: error: target at '/home/karthik/Swift_programs/SwiftCpp/Sources' contains mixed language source files; feature not supported

I'm using Swift version 4.2.3 on Ubuntu 18.04 LTS.

Here's the code :

main.cpp

#include <iostream>
#include "cpplib.h"

int main() {
    std::cout << cpplib::five();
    return 0;
}

cpplib.cpp

#include "include/cpplib.h"

namespace cpplib {
  int five(){
    return 5;
  }
}

cpplib.h

namespace cpplib{
  int five();
}

cwrapper.cpp

#include "include/cwrapper.h"
#include "cpplib.h"

int cwrapperfive(){
  return cpplib::five();
}

cwrapper.h

#ifdef __cplusplus
extern "C"  {
#endif

int cwrapperfive();

#ifdef __cplusplus
}
#endif

main.swift

import cwrapper
print(cwrapperfive())

How can I solve this?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda